Solution for using Filesort for MySQL order by

Source: Internet
Author: User

http://blog.csdn.net/yangyu112654374/article/details/4251624

such as an SQL statement

SELECT * from TABLE1 where a1=1 and a2=2 and a3=3 order by A4 ASC;

After optimization: Select A4,a1,a2 ... From TABLE1 where A1=1 and a2=2 and a3=3 order by A4 ASC; And index the A4,A1,A2,A3, when using order by A4, the Federated index should put A4 in the first place.

The order by field must appear when select is in line

2. From the above can be seen in the federated index, or can be called Multi-column index, such as key (' A1 ', ' A2 ', ' A3 ', ' A4 ') and so on, the sort of thinking is generally, first follow the A1 to sort, A1 the same, and then sort by A2, and so on (A1), (A1,A2) A2,A3) indexes are valid, but indexes such as (A2,A3) are not valid.

Solution for using Filesort for MySQL order by

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.