I have tried creating my mysql tables with both UTF-8 and Latin1 Char sets. When I use Latin1 my indexes are used, when I use UTF-8 indexes are not used when selecting/limiting records. Is there something I am missing with the Char sets that causes this to happen?
Cheers
Ke
Indexes can be used only when the expression’s collation matches that on the indexed column.
If the expression’s
COERCIBILITYis lower than that of the column (that is2), the column’s collation is casted to that of the expression, and the index is not used.Normally, literals have
COERCIBILITYof4and user variables that of3, so this should be not a problem.However, if you mix different collations in a
JOINorUNION, the cast order is not guaranteed.In this case you should provide explicit collation to the column your are casting (most probably, you want to cast
latin1toUTF8), and this should be the collation of the column you are casting to: