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

The sql statement execution flow of mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

1. Client and server establish a connection, and client sends sql to server (corresponding to the process of connector)

2. If server finds the sql in the query cache, it will directly use the result of the query cache to return to the client. If it is not in the query cache, then proceed to the following step (for the query cache process, the 8.0 process no longer exists, and 8.0 completely abandons this function)

3. Server parses the sql to identify whether the string in the sql conforms to the standard, such as the select keyword cannot be misspelled (corresponding to the parser process)

4. Server analyzes the semantics of sql and identifies the specific meaning of the strings in sql, such as T1 is the table name and C1 is the column name (corresponding to the parser). 3 and 4 steps are actually the process of parsing, which is the work of the analyzer, not the optimizer)

5. Server determines the execution path of sql, such as index or full table, which table goes first and which table goes after multiple table joins. When there is a conflict between the readability and efficiency of your where conditions, the mysql will be automatically optimized, that is, everyone understands to rewrite the where clause (corresponding to the optimizer process).

6. Server checks the permissions of the users who execute sql, such as whether the table has the permission to execute (corresponding to the executor process)

7. Server executes the sql statement and sends the result to client (corresponding to the process of the executor)

Connector-- > query cache-- > analyzer-- > optimizer-- > executor

If there is no field C1 in table T1, and executing select * from T1 where C1 column 1 will report that the column C1 does not exist, this process corresponds to the fourth process above, corresponding to the parser process.

If the user does not have permission to the T1 table and executes select * from T1 where C1room1, it will report an error that the user does not have permission to the table T1. This process corresponds to the sixth procedure above, which corresponds to the executor process.

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

Database

Wechat

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

12
Report