About mysql query optimization in terms of limit

When a large amount of data in the database, to read the data required to do with limit tab

limit offset, n

Testing found that the use limit, the value of the offset is greater the longer the query length, the lower the efficiency of the query

select id from table limit 2000000, 100;

At this point, you can use the method where id + modify this sql statement, query optimization:

select id from table where id>2000000 limit 100;

Because the primary key index id are generally higher query efficiency

Guess you like

Origin www.cnblogs.com/fxm1/p/11317061.html