MySQL Forums
Forum List  »  Optimizer & Parser

How to optimize the "order by" & "limit" query?
Posted by: Jiangyubao Jiangyubao
Date: December 18, 2006 09:48AM

Hello, I am a student from Beijing China.I create a table named Employee in MySQL5 and insert 500000 records.Then I send the following query string to mysql client to execute:
(1)select * from Employee as e order by e.id desc limit 499990,10
(2)select * from Employee as e limit 499990,10

The first query take about 4 seconds to complete, but the second query take only about 0.35 seconds to eomplete.

Will anybody tell me how to optimize such query?



Edited 1 time(s). Last edit at 12/18/2006 09:51AM by Jiangyubao Jiangyubao.

Options: ReplyQuote


Subject
Views
Written By
Posted
How to optimize the "order by" & "limit" query?
3313
December 18, 2006 09:48AM


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.