当前位置:网站首页>MySQL Architecture - logical architecture
MySQL Architecture - logical architecture
2022-07-04 22:38:00 【swttws.】
Catalog
One 、 Organize logical architecture
Two 、 Inquire about SQL Execution cycle
1、 Modify the configuration file , Turn on query cache
2、 Open the query execution plan
3、 Execute the same query statement twice
4、 Shows the most recently executed SQL sentence
5、 Inquire about 6,7 Implementation plan
One 、 Organize logical architecture
MySQL Mainly reflected in the storage engine architecture , The plug-in storage engine architecture separates query processing from other system tasks and data storage and extraction . Here's the picture :
1、 adjoining course
(1) Serve client connection , Contains the local socket Communication and most are client based / The implementation of server-side tools is similar to tcp/ip Communication for ;
(2) It mainly completes connection processing , Authorized certification , Safety treatment ;
(3) Introduce thread pool , Provide threads for secure authenticated clients ;
(4) Also on this layer, we can implement the system based on SSL Security links for . The server will also verify the operation permissions it has for each client of secure access .
2、 Service layer
This layer architecture mainly completes most of the core service functions , Such as SQL Interface , And complete the cache query ,SQL Analysis and optimization of some built-in functions .
(1)Management Serveices & Utilities: System management and control tools ;
(2)SQL interface : Accept users SQL command , And return the user query results ;
(3)Parser: Parser :SQL Command parsing and verification ;
(4) Optimizer: Query optimizer ;
(5) Cache and Buffer: If the query cache has a hit query result , The query statement can directly query the cache to fetch data . The caching mechanism consists of a series of small caches . For example, table caching , Record the cache ,key cache , Authority cache, etc .
3、 Engine layer
Storage engine layer , The storage engine is really responsible for MySQL The storage and extraction of data in , Server pass API Communicating with the storage engine . Different storage engines have different functions , So we can choose according to our actual needs .
4、 Storage layer
Data storage layer , It mainly stores the data on the file system running on the bare device , And complete the interaction with the storage engine .
Two 、 Inquire about SQL Execution cycle
1、 Modify the configuration file , Turn on query cache
(1) Modify the configuration file /etc/my.cnf, Add a new line :query_cache_type=1
restart MySQL service
systemctl restart mysqld
2、 Open the query execution plan
show variables like '%profiling%';
set profiling=1;
3、 Execute the same query statement twice
select * from mydb.mytbl where id=1 ;
4、 Shows the most recently executed SQL sentence
show profiles;
5、 Inquire about 6,7 Implementation plan
(1)6 Implementation plan of
show profile cpu,block io for query 6;
(2) Inquire about 7 Implementation plan of
show profile cpu,block io for query 7;
You can find 7 The number executed is higher than 6 A lot less information , It shows that the query statement can get data from the cache ,SQL Statements must be consistent to cache hits , If the · database insert,update,delete, Cache will be invalidated
3、 ... and 、 Query process
1、mysql The client connects to the server , Send query statement , The server will check the cache first (query cache), If there is the same statement as the query statement in the cache , Direct return , Otherwise, parse the statement ;
2、 If a query result is already in the cache , The server will no longer parse the query 、 Optimize 、 And perform . It simply returns the results in the cache to the user , This will greatly improve the performance of the system ;
3、 Syntax parser and preprocessor : First mysql Pass the keyword will SQL Statement parsing , And make a corresponding one “ The parse tree ”;
4、mysql The parser will use mysql Syntax rules validate and parse queries ;
5、 The preprocessor is based on some mysql The rule further checks that the parse tree is legal , When the query optimizer when the parse tree is considered legal , And the optimizer converts it into an execution plan ;
6、 A query can be executed in many ways , All return the same result . The function of the optimizer is to find out The best execution plan .
7、 then ,mysql Default BTREE Indexes , And a general direction is : No matter how tossed sql, At least for the moment ,mysql Only one index in the table is used less .
边栏推荐
- MySQL storage data encryption
- Introducing QA into the software development lifecycle is the best practice that engineers should follow
- 模拟摇杆控制舵机
- 2022-07-04: what is the output of the following go language code? A:true; B:false; C: Compilation error. package main import “fmt“ func main() { fmt.Pri
- The table is backed up in ODPs. Why check m in the metabase_ Table, the logical sizes of the two tables are inconsistent, but the number of
- NFT insider 64: e-commerce giant eBay submitted an NFT related trademark application, and KPMG will invest $30million in Web3 and metauniverse
- Tiktok actual combat ~ the number of comments is updated synchronously
- Now MySQL cdc2.1 is parsing the datetime class with a value of 0000-00-00 00:00:00
- 攻防世界 MISC 进阶区 Erik-Baleog-and-Olaf
- Force buckle 3_ 383. Ransom letter
猜你喜欢
Huawei Nova 10 series released Huawei application market to build a solid application security firewall
It is said that software testing is very simple, but why are there so many dissuasions?
将QA引入软件开发生命周期是工程师要遵循的最佳实践
LOGO特训营 第二节 文字与图形的搭配关系
Breakpoint debugging under vs2019 c release
Locust performance test - environment construction and use
Éducation à la transmission du savoir | Comment passer à un test logiciel pour l'un des postes les mieux rémunérés sur Internet? (joindre la Feuille de route pour l'apprentissage des tests logiciels)
达梦数据凭什么被称为国产数据库“第一股”?
LOGO特訓營 第一節 鑒別Logo與Logo設計思路
攻防世界 MISC 进阶区 Erik-Baleog-and-Olaf
随机推荐
Common shortcut keys for hbuilder x
虚拟人产业面临的挑战
PHP short video source code, thumb animation will float when you like it
More than 30 institutions jointly launched the digital collection industry initiative. How will it move forward in the future?
关于栈区、堆区、全局区、文字常量区、程序代码区
LOGO特训营 第四节 字体设计的重要性
Test will: bug classification and promotion solution
都说软件测试很简单有手就行,但为何仍有这么多劝退的?
Common open source codeless testing tools
模拟摇杆控制舵机
攻防世界 MISC 进阶区 Erik-Baleog-and-Olaf
LOGO特訓營 第一節 鑒別Logo與Logo設計思路
【烹饪记录】--- 青椒炒千张
MYSQL架构——用户权限与管理
The Sandbox 和数字好莱坞达成合作,通过人力资源开发加速创作者经济的发展
攻防世界 MISC 进阶区 Ditf
High school physics: linear motion
Huawei Nova 10 series released Huawei application market to build a solid application security firewall
短视频系统源码,点击屏幕空白处键盘不自动收起
攻防世界 MISC 进阶区 hong