I m writing a query:
select * from table_name order by id limit 21
Until i use the limit is lesser or equal to 20 the rows getting scanned is equal to the exact fetching rows (for example if the limit is 10, than the scanned rows also 10 only). If the limit exceeds 20 the table getting scanned fully.
The only one index created for the primary key id only. Can anybody tell the reason for the full table scan in this case?
My table has 1099 rows.
Explain Result:
---------------------------------------------------------------------------
id|selecttype|table |type|possiblekeys|keys|key_len|ref |rows| Extra
---------------------------------------------------------------------------
1 | SIMPLE |tablen|ALL | null |null|null |null|1099|Usingfilesort
---------------------------------------------------------------------------