Order for Mysql SQL Performance Optimization

Source: Internet
Author: User

Mysql SQL Performance Optimization-order mysql's order will be affected by the amount of data selected during sorting. The more data columns, the slower the sorting. To illustrate this problem, see several examples. Low performance: select id, job_name from test_results where id <96836230 order by id desc limit 390; 1 rows fetched (MS) High Performance: select id, job_name from test_results where id = (select id from test_results where id <110836230 order by id desc limit 281) limit 1; 1 rows fetched (MS) Efficient paging query www.2cto.com low performance: select id, job_name from test_results order by id desc limit 1200000,100; 100 rows fe Tched (34.616 sec) High Performance: select id, job_name from test_results join (select id from test_results order by id desc limit 1300000,100) as t2 using (id); 100 rows fetched (5.460 sec) next, let's analyze the cause. First, start from the execution sequence of mysql, and start from top to bottom: www.2cto.com FROM <left_table> ON <join_condition> <join_type> JOIN <right_table> WHERE <where_condition> group by <group_by_list> HAVING

Related Article

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.