MySQL Forums
Forum List  »  Performance

Re: How MySQL Uses Indexes
Posted by: Rick James
Date: May 06, 2013 07:57PM

> why does not mysql use index when necessary, should I force the use of index manually?

Generally, no.

Finding when something is between two columns is especially difficult for the optimizer. (I assume your `i` and `o` are start and end times?

In that use case, typically, each part of the WHERE clause will match maybe half of the table -- that's not very useful for filtering.

> I conclude that mysql optimizes the query for the best performance,

Yes, even if it means ignoring all the indexes. (Sometimes the optimizer will goof, but not very often.)

I suspect you have over-simplified your real case. There are other tricks that may apply; can we see the real CREATE TABLE and the real SELECT?

Options: ReplyQuote


Subject
Views
Written By
Posted
2241
May 04, 2013 08:28AM
924
May 06, 2013 10:31AM
Re: How MySQL Uses Indexes
951
May 06, 2013 07:57PM
932
May 07, 2013 12:24PM
835
May 07, 2013 07:47PM
830
May 08, 2013 05:33AM
840
May 08, 2013 09:04PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.