Understand filesort in the Explain command output

Source: Internet
Author: User
Tags percona
Some time ago I read the last article about filesort in mysqlperformanceblog, And I saw Percona often asked the applicant "what is the meaning of filesort IN THE Explain command output" during the recruitment interview, it is strange that the correct answer is basically not obtained. This is a very basic content.

Some time ago I read the last article about filesort on mysqlperformance blog. When I saw Percona's job interview, I often asked the applicant the question "what is the meaning of filesort IN THE Explain command output, it is strange that the correct answer is basically not obtained. This is a very basic content.

Some time ago I read the last article about filesort on mysqlperformance blog. When I saw Percona's job interview, I often asked the applicant the question "what is the meaning of filesort IN THE Explain command output, it is strange that the correct answer is basically not obtained.

This is a very basic content. Since you dare to apply for a job from a company like Percona, you should not be clear about this problem.

So I also tentatively asked a few friends in the MySQL circle this question. The result is basically the same as that of Percona. only 1/10 of my friends really understand the meaning of filesort, the answer to the error is similar to the answer from Percona. It is because the temporary table is too large during mysql sorting and exceeds the MySQL limit. You need to write the data to the disk file for sorting, this is called filesort.

Most of the "seemingly correct" answers are probably guessed by the literal meaning of the word "filesort. It seems that not only Chinese people like "Wang wenshengyi", but also foreigners!

What does filesort in the output of the Explain command mean? In fact, it is very easy to tell you That MySQL needs to perform actual sorting operations instead of obtaining sorted data through indexes.

I personally think the above incorrect answer is at least two points:

  • Filesort (in fact, sorting) may not necessarily generate temporary tables.
  • There is no direct connection between filesort and the writing of temporary table data to the disk.

The first point in the above two errors is also mentioned in the MySQL Performance Blog article.

In fact, the implementation analysis of MySQL order by in my previous article has clearly analyzed MySQL's sorting, the temporary table must be used only when the returned data and sorting conditions are not in the same table.

It is really very rigorous to learn the technology. If we simply guess its meaning by literal meaning, without carefully reading the document and analyzing the experiment, the answer may be wrong in many cases.

Original article address: Understand filesort in the Explain command output. Thank you for sharing it with the original author.

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.