MySQL: SELECT with Index Hint option to Optimize the Query

The Table Indexes are always the main focus to improve the performance of any SQL Query.
In MySQL, We can provide INDEX Hint to Query Optimizer for choosing our analyzed Index.

In most of the cases, Query Planner and Query Optimizer are accurate to choose perfect Index.
But sometimes, still It is required to give Index Hint for reducing the overall Query Planning Time.

If we know that this Index is good for this query, we should Provide the Hint to Query Optimizer.

Here, You can also access one related article.

MySQL: Script to find Index Usage Statistics of a Database

MySQL supports command like USE INDEX, IGNORE INDEX, FORCE INDEX, which we can use for Index Hint.

The USE INDEX hint tells MySQL to use only one of the named indexes to find rows in the table.
The IGNORE INDEX tells MySQL to not use some particular index or indexes.
The FORCE INDEX hint acts like USE INDEX , with the addition that a table scan is assumed to be very expensive.

Prepared small demonstration on this.

Create a sample table:

Insert few sample Records:

Create few sample Indexes:




Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from

Leave a Reply

Be the First to Comment!

Notify of