当前位置:网站首页>MySQL 45 lecture notes (I) execution of an SQL statement
MySQL 45 lecture notes (I) execution of an SQL statement
2022-06-22 03:39:00 【Comtom】
One sql Execution of statements
One .Mysql Basic framework
SELECT
*
FROM
T
WHERE
ID = 10;

MySQL Can be divided into Server Layer and storage engine layer
- server Layers include The connector 、 The query cache 、 analyzer 、 actuator 、 Built in functions ( date , Time , Digital and encryption functions, etc ), All the functions across storage engines are implemented in this layer , such as stored procedure , trigger , View etc. .
- Storage engine layer be responsible for Data storage and extraction : Its architecture pattern is plug-in , Support InnoDB,MyISAM,Memory Wait for multiple storage engines
- The most commonly used engine is InnoDB, from MySQL5.5.5 edition Start default storage engine .
Two . The connector
The connector is responsible for communicating with the client Establishing a connection , Access permissions , Maintenance and management Connect :
mysql -h$ip -P$port -u$user -p
- User name password authentication passed , The connector will find out the permissions you have in the permission table
- After the user successfully establishes the connection , You use the administrator account to modify the permissions of this user , It will not affect the permissions of existing connections
- After modifying user permissions , You need to create a new connection to use the new permission settings
Long connection to database
- A long connection After the connection is successful , If the client continues to have requests , Always use The same connection ( recommend )
- Short connection It means to disconnect after a few queries , Create a new one for the next query
Long connection disadvantages
- Too much memory :Mysql The memory used temporarily during execution is managed in the connection object , These resources will not be released until the connection is disconnected , So long connections accumulate , This leads to too much memory , Forced by the system (OOM)
The solution of using too much memory for long connections
- regular Disconnect the long connection
- perform mysql_reset_connection Reinitialize connection resources
3、 ... and . The query cache
- MYSQL After getting a query request , Meeting Query cache first have a look , Was it before Executed this statement
- The query information will be displayed as key-value On the form of , direct Cache in memory in .
- key Is a query statement ,value Is the query result
- Statement is not in cache , Will continue Subsequent execution writes the results back to the query cache in
Query caching often does more harm than good
- The query cache fails frequently , Any update, modification, deletion , Metropolis Invalidate the query cache
- MySQL8.0 There will be no query cache after version
Four . analyzer
- Lexical analysis
- Syntax analysis
5、 ... and . Optimizer
- The optimizer is when there are multiple indexes in a table , Decide which index to use
- A statement has multiple table associations (join) To determine the connection order of each table
SELECT
t1.*
FROM
t1
LEFT JOIN t2 ON t2.d = 20
WHERE
t1.c = 10
The optimizer will determine whether the index can be moved , Choose the fastest execution method
6、 ... and . actuator
MySQL adopt The analyzer knows what you're going to do , adopt Optimizer know How do you do it? , Enter the actuator stage , Start Execute statement
Execution steps
1. Authority verification - Whether you have permission to query, modify or delete this table
2. Call the storage engine to execute
边栏推荐
猜你喜欢

EU5, eu7, EX3, Ex5 install third-party apps

微信小程序聊天 表情
![[网鼎杯 2018]Fakebook1 参考](/img/c8/a9d77308b6cc542c8c47a570b9234c.png)
[网鼎杯 2018]Fakebook1 参考

告警日志中出现ORA-48132 ORA-48170

多线程 interrupt用法

svn与cvs的区别有哪些

3000 yuan projector comparison and evaluation, dangbei D3x beats Jimi new Z6 x

泛微 E-cology V9 信息泄露漏洞

Wechat applet ChAT expression

VIM from dislike to dependence (18) -- advanced search mode
随机推荐
128陷阱——源码分析
作为接口的模板
所有项目的资源
FastDFS-6.0.6
3DE robot suction cup grabbing box
我们如何解决了RealSense偏色问题?
Policy mode
Talk about the Flink waterline
Nebula Graph学习篇2_版本v2.6.1之前的bug导致OOM
C language integer value range - the problem of more than one negative number
[QNX Hypervisor 2.2用户手册]5.5 启动和使用Guest
Mysql 45讲学习笔记(四)索引
rabbmitMQ 发布关键字模式<三>
rabbmitMQ 发布订阅模式<二>
C51的一些日记
How to randomly assign 1000 to 10 numbers
rabbmitMQ 简单模式<一>
倍福TwinCAT 3 气缸动作程序编写
Sword finger offer 68 - ii Nearest common ancestor of binary tree
ASUS reinstallation system keyboard lamp failure = & gt; Refitting the ATK drive