MySQL Forums
Forum List  »  Optimizer & Parser

ORDER BY Optimization depends on LIMIT
Posted by: Goran Prijic
Date: March 24, 2011 04:38AM

Hi,

I have this query

SELECT *
FROM `content` AS `c`
WHERE c.module = 20
AND c.categoryID
IN ('50', '31', '16', '10')
ORDER BY `c`.`released` DESC
LIMIT 5

Table has approximately 500 000 rows but this query should not return any.

This query will execute with ORDER BY optimization when LIMIT is less than 4. When LIMIT is greater than 4, using filesort will be run.

Does anyone know how ORDER BY optimization depends on LIMIT and how this dependency can be changed?



Edited 2 time(s). Last edit at 03/24/2011 08:50AM by Goran Prijic.

Options: ReplyQuote


Subject
Views
Written By
Posted
ORDER BY Optimization depends on LIMIT
5363
March 24, 2011 04:38AM


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.