Mysql Limit paging query optimization details, mysqllimit

Source: Internet
Author: User

Mysql Limit paging query optimization details, mysqllimit

Select * from table LIMIT 5, 10; # return data in rows 6-15 select * from table LIMIT 5; # Return the first 5 rows select * from table LIMIT; # Return the first 5 rows

Let's write pages.

Physical Paging

Select * from table LIMIT (current page-1) * number of entries per page, number of entries per page;

MySQL Limit simple optimization. md

Is it the same as taking the first 90000 records, the traditional method or the transformation method?

The traditional method is to take the first 90001 records, take the largest ID value as the starting ID, and then use it to quickly locate the next 100 records.

The transformation method is to take only the last one of the 90000 records, and then take the ID value as the starting marker to locate the next 100 records.

Conventional execution result. 100 rows in set (0.23) sec

Transformation Method execution result. 100 rows in set (0.19) sec

-- Transformation Method-> abbreviated method SELECT * FROM table where id> = (select id from table order by id limit 90000,1) limit 100;

The above is a detailed description of Mysql Limit paging query optimization introduced by xiaobian. I hope it will be helpful to you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.