MySQL Forums
Forum List  »  Performance

Re: order by primary key slowly
Posted by: Rick James
Date: April 12, 2016 07:42PM

Maybe the real answer is "Don't do that!".

Why are you using huge offsets? Are you walking through the table? Is a human doing such? I doubt it. It would be painfully tedious to press the Next button 100000 times.

A better way is to "remember where you left off". See my blog on such: http://mysql.rjweb.org/doc.php/pagination

Back to the question and replies...
* Neither query sorts. The one using the 'type' index has no ORDER BY; the one by 'id' takes advantage of the table being ordered by 'id'.
* When using LIMIT, EXPLAIN often lies in the 'Rows' and 'Filter' columns.
* Did you "time" your queries twice? The first time may be slow because of I/O; the second may be faster because of caching. Use the second.
* Add SQL_NO_CACHE (or turn off the Query cache) so that the QC does not give you a time of "0.00 seconds".

Options: ReplyQuote


Subject
Views
Written By
Posted
2774
April 05, 2016 10:42PM
1205
April 06, 2016 10:15AM
1236
April 06, 2016 11:23AM
1338
April 06, 2016 08:11PM
1269
April 06, 2016 10:35PM
1245
April 07, 2016 12:34AM
1304
April 07, 2016 10:20AM
1214
April 07, 2016 11:26PM
Re: order by primary key slowly
1317
April 12, 2016 07:42PM
1175
April 06, 2016 08:57AM
1194
April 06, 2016 10:17AM


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.