Page 1 of 1

MySQL Index Selection

Posted: Sat 02 Aug 2014 19:59
by rkondner
Hi,
Forum Newbie with MyTable Question:

If I have a table with multiple indexes, say indexes on Col_1 and Col_2, and if I use a .Locate method on Col_2 will MySQL automatically use the proper index?

I noticed there was no IndexName property but I did see Index Fields. I would think the RDBMS would take care of such issues. Is this correct?

Thanks,
Bob K

Re: MySQL Index Selection

Posted: Mon 04 Aug 2014 09:30
by ViktorV
If you use the Locate method on Col_2, MySQL cannot use the index. If a table has a multiple-column index, any leftmost prefix of the index can be used by the optimizer to find rows. MySQL cannot use the index to perform lookups, because Col_2 do not form a leftmost prefix of the index.
More details about how MySQL uses indexes can be found at http://dev.mysql.com/doc/refman/5.0/en/ ... dexes.html