MySQL Forums
Forum List  »  Optimizer & Parser

Re: Limiting query research to a specified n. of records
Posted by: Björn Steinbrink
Date: March 16, 2007 09:59AM

MySQL will stop searching for records once it has found enough to satisfy the LIMIT clause. But if you use an ORDER BY clause and there's no index that MySQL can use to retrieve the rows in the requested order, of course all rows have to be fetched first, then sorted and finally the N requested rows are sent to the client.
If that is the case for you, you'll have to add an index that helps MySQL fulfilling the ORDER BY requirement, which will again make it stop reading rows once enough are found to satisfy the LIMIT.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Limiting query research to a specified n. of records
2071
March 16, 2007 09:59AM


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.