Multi-Column Indexes, field order, and performance.

"Mark Smith" <[email protected]> Thu, 7 Sep 2006 10:49:27 -0700
Newsgroups gmane.comp.db.mysql.windows
Message-ID <4E09E88532EA944996E0ACA86B32024C79C129@exch11knsm.win.keynote.com>
Hello I have a question on using a Index that spans multiple fields
INDEX(a,b,c).

 

If my queries, that use this index, all have where conditions that
include all three fields; does it matter about the index order for query
performance?

 

In other words is INDEX(a,b,c) = INDEX(c,b,a) or any combination there
in?  Is it true for all index types or Databases for that matter (MySQL,
Oracle, MSSQL)?

 

I am in a quandary because the last component in this case is time
(field c).  I have been asked to aggregate across the time dimension for
fields a and b.  Because now a and b are no longer conditions in the
where statement (now included in the group by) using the existing index
is no longer possible or feasible.  Because of legacy SQL code I am
worried about simply changing the order at this time.  Adding a second
index is frowned upon due to the huge nature of the table and the space
requirements.

 

Thanks.