mysql - get different result using select * and select askid -
that sounds wired,i find when try optimize limit
.
askid pk , table has 1.14m rows.
can not give table because it's in production environment.
i try
select askid ask limit 1000000,1;
return 1001747
then try
select * ask limit 1000000,1;
return 1000627
askid has index , influence result, think result should same,isn't it?
select askid ask order askid limit 1000000,1;
return 1000627.
but why order by
matters?is there wrong askid index?
the performance different.
first 1 takes 0.2s;
second takes 2s;
third 1 takes 1s;
how optimize , right result?
the mysql version use 5.6.10
sql makes no guarantees in regards row order, chooses whatever makes best plan based on query.
if expect order, specify using order by
. , should if you're limiting result set.
Comments
Post a Comment