That sounds wired,I find this occasionally when I try to optimize limit
.
askid is PK and the table has 1.14M rows.
I can not give the table because it's in production environment.
I try
SELECT askid FROM ask limit 1000000,1;
return 1001747
Then I try
SELECT * FROM ask limit 1000000,1;
return 1000627
askid has index and it influence the result, but I think the result should be same,isn't it?
SELECT askid FROM ask ORDER BY askid LIMIT 1000000,1;
return 1000627.
But why ORDER BY
matters?Is there something wrong with the askid index?
The performance is much different.
The first one takes 0.2s;
the second takes 2s;
the third one takes 1s;
How to optimize it and get the right result?
The mysql version I use is 5.6.10