MySQL Forums
Forum List  »  Performance

Re: Queries locking up
Posted by: Rick James
Date: May 11, 2013 11:29PM

LIKE with a leading wildcard (%) cannot be optimized. So there is no use adding it to the INDEX.

The same index should work nicely:
INDEX(item_type_id, has_photo, normalized_time)
It will use the first two fields to satisfy (partially) the WHERE clause.
Then, (I think, but I am not sure), it will fetch the rows in normalized_time order. This will prevent a sort later.

EXPLAIN that query. If it does not say filesort, the my guess was right.

"Pagination via OFFSET and LIMIT" (LIMIT ?,?) is inefficient.
http://mysql.rjweb.org/doc.php/pagination

Options: ReplyQuote


Subject
Views
Written By
Posted
2211
May 07, 2013 01:13PM
923
May 08, 2013 08:50PM
816
May 09, 2013 10:09PM
Re: Queries locking up
989
May 11, 2013 11:29PM
725
May 15, 2013 09:33PM


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.