MySQLSQL optimization: SQL crawler page turning Optimization

Source: Internet
Author: User

In the past few days, I will share and summarize some SQL experience optimized in the past few days. The first thing to share is to optimize the limit page for MyISAM. Background: A business system provided by the company to crawlers to capture data. Basic information: the MySQL version is 5.1 and the engine is MyISAM. The original SQL content is roughly as follows: Note: To avoid sensitive information, change many fields to col without affecting reading :-)
SELECT Aa. *, B. col, B. col, C. col, C. col FROM (select. col,. col,. col,. col,. col,. col,. col,. col,. col,. col,. col,. col from a where. class1id = 1000000 AND 1 order by. oktime desc limit 286660,20) Aa left join B ON Aa. class2id = B. id left join c on Aa. username = C. username

SELECT Aa. *, B. col, B. col, C. col, C. col FROM (select. col,. col,. col,. col,. col,. col,. col,. col,. col,. col,. col,. col from a inner join (SELECT askid FROM solve_answerinfo use INDEX (idx_1) WHERE class1id = 1000000 order by oktime desc limit 389300,20) aaa USING (askid) Aa left B ON Aa. class2id = B. id left join c on Aa. username = C. username;
Create index idx_1 on solve_answerinfo (oktime, askid, class1id );

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.