Wednesday, March 21, 2012

MySQL specify index without FORCE INDEX

Here's a blog post from Shlomi Noach which displays some useful steps to consider when optimizing MySQL querie where MySQL chooses an inefficient index.
It helped me. Especially the part about tricking MySQL to not use an index, without using USE INDEX or FORCE INDEX (which can be very bad if you have a dynamic query or your tables change/grow, something they usually do).

http://code.openark.org/blog/mysql/7-ways-to-convince-mysql-to-use-the-right-index

Note that Solution #7: Make MySQL think the problem is harder than it really is can also be applied to GROUP BY. e.g. GROUP BY id, type, level

No comments:

Post a Comment