当前位置:网站首页>MySQL architecture
MySQL architecture
2022-06-24 01:34:00 【Xiao Wange】
mysql8.0 Architecture
Look at the picture mysql Service is a c/s framework It is to use c and c++ Developed
Connectors End
Can pass , Various clients , link mysql The server Such as mysql command , Various apl etc.
server End
It is divided into many modules
Link layer
1 Provide link agreement TCP/IP The local socket
2 User name password verification ( The authentication database through the authorization table is started , The authorization table will be loaded into memory mysql.user mysql.db mysql.table_priv mysql.column_priv)
3 Provide link thread
View linked threads show processlist;
View all threads in the background select * from performance_schema.threads\G
sql layer
sql Thread receiving link thread
Preprocessing (lex) grammar , semantics ( What kind of statements are ), jurisdiction ( Do you have permission to access the library or table ) Check
analysis (yacc) Generate parse tree (ast Abstract syntax tree )
Optimize Logic optimization Equivalent transformation based on relational algebra , In physical optimization Refer to statistics ( It describes , The distribution of data , Some status of the index , Roughly record how many lines there are in the table ) And some optimizer algorithms , Cost assessment , Generate execution plan (explain)
Description of Statistics The statistics record The state of the table , Table name data row Data distribution Index status information ... The statistics are mysql Collected regularly Through some parameter indexes Not collected in real time mysql.innodb_index_stats mysql.innodb_table_stats # problem One sql The statement ran well yesterday (0.01 second ) , Suddenly it slows down (2min)? Why? Due to inaccurate statistical information , It is caused by not going through the index You can force a re collection by command There is also parameter control analyze teble Library name . Table name ; perhaps optimize table Library name . Table name ; # Command lock table Use caution
Engine layer
io Thread receive sql Threads
mysql Dealing with disks is similar to linux File system
innodb Storage engine is divided into memory structure and disk structure
Macro structure of storage
stay mysql In a database , It is a directory in the system
stay mysql One of the tables Corresponds to one of the operating systems .ibd file (8.0)
In the operating system, you can use ibd2sdi file name You can view the files
In the table data row + Metadata ( Table properties , Columns of the table ( Column properties ), Table name ) mysql8.0 How tables are stored The data of each table is stored in ibd In file mysql5.7 How tables are stored data row ibd file Source data frm +ibdata1( The overall ) file Online DDL It will be faster
8.0 New features understanding
metdata Structural changes 5.7 Version of the problem Two sets of data dictionary information server layer .frm innodb The data dictionary DDL Unable to atomize ( When deleting two tables , Not together ) frm and innodb Layers will be inconsistent Concurrency needs to be handled with care (MDL,dict_sys::mutex,dict_sys::rw_lock) The crash cannot be recovered 8.0 New characteristics Support transactional DDL, Crash can be rolled back , To ensure consistency , Keep only one copy of the data dictionary information , To cancel the frm The data dictionary The data is all in the InnoDB In the table Adopt sleeve locking mechanism , Manage concurrent access to data dictionaries (DML) all-new plugin Support 8.0.17 Then add clone plugin, Better support MGR InnoDB Clustre Node management of The secure encryption method changes Change the encryption method to caching_sha2_password SSL Will support to TLSv1.3 edition . Changes in user management and authentication methods Change the authorization method Join in role Role permissions Add more permissions cache&&Buffer The change of To cancel the Query Cache The result of the query is cached You will make a query statement hash The result is key If you add the query criteria The cache will not hit mysql The query cache for is not a cache execution plan , It's a query and its result set , This means that only the same query operation can hit the cache , hide mysql The query hit rate is very low oracle What is cached is the execution plan Reduce understanding of the process .
mysql example
mysqld Daemon + Master Threa + Worker Threads + Pre allocated memory
mysql Memory structure global buffers( overall situation ) innodb_buffer_pool( You can set the physical memory %50-%75): Data buffer innodb_log_buffer: Log buffer key_buffer table_cache session buffers( Each session is used independently ) read_buffer read_fnd_buffer sort buffer join buffer tmp table binlog_cache
mysql Thread in master thread Function as the core background process , Responsible for global management data refresh and data consistency processing io thread Responsible and disk io Interaction (read io write io insert buffer log io) Related parameters inndbo_read_io_threads, inndbo_write_io_threads Purge thread effect UNDO Page recycling Parameters innodb_purge_threads page cleaner effect Dirty page refresh thread Default 1 Maximum 64 Parameters innodb_page_cleaners other threads
边栏推荐
- Gin framework: automatically add requestid
- [new secsha!] Have you got the 22 year new seckill activity of Tencent cloud?
- The best Base64 encoding and decoding tutorial in the whole network, with 6 examples!
- Horizontal movement of Intranet penetration -- password spray attack from domain to domain
- JS stack memory
- Remove the cloud disk service display "continued" logo
- Devops culture: Amazon leadership principles
- [technical grass planting] cdn+ lightweight server +hugo= let the blog "cloud native"
- [flutter] comment utiliser les paquets et plug - ins flutter
- S2b2c e-commerce platform in the pharmaceutical and medical industry enables enterprises to grasp differentiated competitive advantages and improve supply chain efficiency
猜你喜欢
随机推荐
Many ministries and commissions strengthened regulation, and Tencent security helped enterprises resist the "mining" Trojan horse
How to build a high-quality website
[technical grass planting] cdn+ lightweight server +hugo= let the blog "cloud native"
Tke cluster setup linkerd2
Esp8266 OTA remote and wireless upgrade
Analysis of the whole process of webapck5 core packaging principle
Go language core 36 lectures (go language practice and application VII) -- learning notes
How to use IOT gateway to realize networking communication of smart road lamp posts
Feasibility of importing UE4 using gltf with instances
How to self-study website construction is website construction company reliable
The Mars rescue plan has been released. The year of the tiger is limited to dolls waiting for you!
What is the relationship between the Internet of things and artificial intelligence?
Radware load balancer common maintenance query commands
Map design
[technology for grass planting] lightweight 248 helps individual developers go to the cloud
Introduction to easycvr interfacing with Huawei IVS subscription camera and user change request interface
CSDN articles crawl the top ten bloggers' articles and convert them to MD
Clubhouse online supports replay function; Webobs live streaming tools are going to be popular |w
What is pension finance? What are the pension financial products?
Golang gets the start timestamp and end timestamp of a past or future week or month
![[flutter] comment utiliser les paquets et plug - ins flutter](/img/a6/e494dcdb2d3830b6d6c24d0ee05af2.png)
