MySQL Tuning--using Filesort

Source: Internet
Author: User

Tag: The user using ROM uses the RAC statement from the ORDER by nbsp

The solution to this problem is that MySQL can use only one index per query, and your SQL statement's WHERE condition is not the same as the condition of ORDER by, and the index is not built. Then the ORDER by is not used for indexing. A Using filesort problem has occurred.
The problem is to create a hybrid index that includes the WHERE and ORDER by conditions.

For example, the original SQL statement is:

SELECT * from the user U where u.id=100 order by u.update_time

And the index is idx_user_id (ID)
It is now again indexed to Idx_user_id_update_time (id,update_time) and then viewed using the EXPLAIN command. Assume that key is using the newly created Idx_user_id_update_time index above. You can see that the Using file sort problem disappears. Assume that key is not using the new Idx_user_id_update_time index. The ability to use the Force Index () method forces the index to be used, at which point the using Filesort problem is overcome.
SELECT * from User U Force index (idx_user_id_update_time) where u.id=100 order by u.update_time


MySQL Tuning--using Filesort

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.