How is the sql query executed?



Connector

Establishing a link is more complicated. It is recommended to use a long connection. Note that the memory temporarily used by mysql during execution is managed in the connection object.It will only be released when the link is broken.

Solution: 1. Disconnect the link regularly (the general agent layer will do it) 2. Can be used after 5.7mysql_reset_connectionTo initialize the link resource

Show processlist ; -- Check all connections.Copy code

Cache

The key value is stored in the form, the key is the sql statement, and the value is the query result. Caching is not recommended.

Cache suitable for scenes, static tables, such as system configuration table, mysql8.0 completely delete the cache


Analyzer

In addition to this method analysis, it is determined whether the table and the field exist. Both are solved at the analyzer level.


Optimizer

After the parser, mysql already knows what to do, and it needs to be optimized before it is done again. For example, the following sql

select * from t1 join t2 using(ID) where t1.a = 1 and t2.b = 1;Copy code

1. Execute t1 and find a=1, associate t2, and find the value of t2.b=1.

2. Execute t2 and find b=1, associate t1, and find the value of t1.a=1.

The specific use of that rule is determined by the optimizer.


Actuator

Mysql knows what to do through the parser. byThe optimizer knows what to do. Then enter the actuator

First determine whether there is permission, if there is an interface that will call the storage engine, such as the following sql

select * from T where name = 't'; -- name no indexCopy code

1. The innodb storage engine will take the first row of the table, determine whether name is equal to t, not skip, yes to the result set

2. Take the next line and repeat the same logic until you have traversed all the results and then return the satisfied result set to the client.


The rows_examined field in the slow query log can be used until the number of rows scanned by this statement.



Reprinted at: https://juejin.im/post/5cc279ccf265da03bb6fb95c

Intelligent Recommendation

Infrastructure: How is a SQL query executed?

Author | Lin Xiaobin Source | Geek Time "45 Lectures on MySQL Actual Combat" column How is a SQL query executed? Let's disassemble MySQL to see what "parts" are in it. We hope that...

How is a SQL query executed: Infrastructure

We often say that when you look at a matter, don’t get caught up in the details. You should get a bird’s eye view of the whole picture first. This will help you understand the problem from...

(1) How is a SQL query executed

Schematic diagram of MySQL basic structure: MySQL can be divided into two parts: Server layer and storage engine layer. Server layer: Including connectors, query caches, analyzers, optimizers, executo...

How is a MySQL SQL query executed?

1. How is a MySQL SQL query executed? This article is compiled from the notes of the personal subscription geek time "Mysql 45 Lectures". We often say that when you look at a matter, don&rsq...

How a query SQL statement is executed

The database we usually use is usually seen as a whole. For example, we execute a query SQL and return a result set, but we don’t know how this statement is executed inside MySQL. Next, we will ...

More Recommendation

How is L01_ How is a SQL query statement executed?

Guide This article mainly uses a SQL query statement to let us understand the basic architecture of MySQL. 1. MySQL logic architecture diagram Below is the basic architecture diagram of MySQL. From th...

JG-OJ Record 64: 7: Cyclic Foundation-21

describe Enter three positive integers A, B, C, and output the maximum number in the numbers that are smaller than those b or C. enter Three positive integers A, B, C Output The largest number in the ...

Android FrameWork learning (1) Android 7.0 system source code download\compile

Important content Reprinted. Hardware environment requirements 1. Compilation environment According to the official statement, compiling the system source code of Android 2.3.x and above requires a 64...

Export issues of issues in the Gitlab issue library

premise: The project team has always used the Issue library in Gitlab as a platform for project defect management. The previous blog page specifically explained the advantages of using Git for defect ...

Borg Maze(bfs+prim)

The Borg is an immensely powerful race of enhanced humanoids from the delta quadrant of the galaxy. The Borg collective is the term used to describe the group consciousness of the Borg civilization. E...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top