In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you about the order in which statements are executed in mysql. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
The statement of MySQL is divided into 11 steps, as noted in the following figure, the first is always the FROM operation, and the last is the LIMIT operation. Each of these operations produces a virtual table, which serves as an input for processing, except that these virtual tables are transparent to the user, but only the last virtual table is returned as a result. If no corresponding action is specified in the statement, the corresponding step will be skipped.
(7) SELECT (8) DISTINCT (1) FROM (3) JOIN (2) ON (4) WHERE (5) GROUP BY (6) HAVING (9) ORDER BY (10) LIMIT
Let's analyze each stage of query processing in detail.
1. FORM: calculates the Cartesian product of the left table and the right table of FROM. Generate virtual table VT1
2. ON: perform ON filtering on the virtual table VT1, and only those rows that match will be recorded in the virtual table VT2.
3. JOIN: if OUTER JOIN is specified (such as left join, right join), then the unmatched rows in the reserved table will be added to the virtual table VT2 as external rows, resulting in a virtual table VT3. If there are more than two tables in the rug from clause, then step 1-3 will be repeated for the result VT3 generated by the previous join connection and the next table until all tables have been processed.
4. WHERE: perform WHERE conditional filtering on the virtual table VT3. Only matching records are inserted into the virtual table VT4.
5. GROUP BY: according to the columns in the group by clause, the records in VT4 are grouped to generate VT5.
6. CUBE | ROLLUP: perform cube or rollup operations on table VT5 to generate table VT6.
7. HAVING: apply having filtering to the virtual table VT6, and only the matching records will be inserted into the virtual table VT7.
8. SELECT: perform the select operation, select the specified column, and insert it into the virtual table VT8.
9. DISTINCT: deduplicates the records in VT8. Generate virtual table VT9.
10. ORDER BY: sort the records in the virtual table VT9 to generate the virtual table VT10.
11. LIMIT: fetch the record of the specified row, generate the virtual table VT11, and return the result.
Thank you for reading! This is the end of the article on "what is the order of sentence execution in mysql". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.