views:

25

answers:

2

I will design my mysql tables/columns using "multiple column index".

I've checked some articles about "multiple column index". But I can't find information about the option "between" with "multiple column index".

http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html

http://www.mysqlfaqs.net/mysql-faqs/Indexes/When-does-multi-column-index-come-into-use-in-MySQL

So I want to use the query as:

select x_id, date from table_name where x_id = 'x' and date between 'x1' and 'x2'

Is that correctly to use with "multiple column index" ?

As I see , everyone uses that with the option "=" , ">" , "<" , "OR" , there is no example with the option "between". Can I use with the option "between" ?

+1  A: 

Between is the same with > and <. It'll use the index and will have to be the only (or last) part of the index since it implies a range search.

cherouvim
A: 

between will work whether or not you index the columns singly or multiply. You should be bale to check for optimal query use of indexing at runtime.

Randy