Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the execution principle of a query SQL query statement?

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you what is the execution principle of a query SQL query sentence, the content is concise and easy to understand, it can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

First familiarize yourself with the simple and easy-to-understand flow chart of SQL execution. The seven steps of the SQL query process.

1. Query SQL to send request

The client transmits the query sql to the server according to the mysql communication protocol. After the server receives the request, the server sets up a single thread to execute the sql

two。 Before the execution of the select query statement, mysql will determine whether it is a select statement through the command dispenser (whether the first six characters of the sql statement are select); 3. Query cache advance MySQL when query cache is enabled, it will first find out whether the SQL matches exactly in the query cache. If so, verify whether the current user has the query permission. If the permission verification is passed, the result set will be directly returned to the client, and the query will be completed. Continue to execute down if there is no match. 4. Parser of syntactic analysis

If the match is not successful in the query cache, the statement is handed over to the parser for parsing. MySQL knows what to look up by parsing the syntax. This step verifies the syntax and returns a syntax error to interrupt the query if the syntax is wrong. If the syntax is incorrect, You have an error in your SQL syntax5. Query preprocessor

(1) after the work of the parser is finished, pass the statement to the preprocessor to check the existence of the data table and data column, and parse the alias to see if there is ambiguity if the error returns Unknown column xxx in 'where clause'.

(2) whether sql has the permission to operate the table; if wrong

ERROR 1142 (42000): SELECT command denied to user 'root'@'localhost' for table' xxx'6. After the optimizer statement parsing of the query is complete, MySQL knows what to look for, and then passes the statement to the optimizer for optimization (selecting the fastest lookup method through the index) and generates an execution plan. 7. Finally, the executor of the query is handed over to the executor to execute the query statement. After the executor starts execution, it gradually saves the data to the result set, caches the data into the query cache gradually, and finally returns the result set to the client.

The above content is a query SQL query statement what is the principle of execution, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report