Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Mar 042011
 

Force MySQL to use a specific index during query processing

Answer:

Sometimes, the index picked by MySQL might not be the most optimized one, and you want to pick the index to use by yourself.

To do so, you can provide the index hints by doing something like the following.

mysql> SELECT * FROM user FORCE INDEX user_name WHERE name = 'John' AND user_name = 'john2';

So you tell MySQL to use the index user_name, instead of name (if also available).

That's all.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>