I have 29900000 records in table, offset consuming too much query execution time
SELECT * FROM table_records LIMIT 50 OFFSET 1999950
this query taking 33.087 sec
I have changed offset as 2000000
SELECT * FROM table_records LIMIT 50 OFFSET 2000000
this query taking 2.030 sec
explaination
EXPLAIN SELECT * FROM table_records LIMIT 50 OFFSET 29941250
id | select_type | table | type | possible_keys | key | key_len | ref |rows | Extra
1 | SIMPLE | table_records | index | (NULL) | PRIMARY | 4 | (NULL) |29900771 |
I have removed offset just set as limit
SELECT * FROM table_records LIMIT 50
this query taking 0.002 sec
any suggestion or idea appreciated.