当前位置:网站首页>Execution plan of mysql
Execution plan of mysql
2022-08-03 17:39:00 【Bugxiu_fu】
1. What is an execution plan?
Use the EXPLAIN keyword to simulate the optimizer executing SQL query statements, so as to know how MYSQL processes your SQL statements.
Execution planning process (best understood with the diagram)
The browser (client) sends a request. Before executing the database query, it finds the connection pool (recycling), connects with the database driver, finds the mysql service after obtaining the connection, then the connection pool finds the query cache, and then parses it, find the parse tree parsing, generate a new parse tree after preprocessing, query the optimizer after the new parse tree, execute sql, find the data file through the engine, read the data, return it to the cache, and finally return it to the user.
Some optimizers: (understand)
CBO: Cost-based optimizer, look at which index, and count the index according to the cost value.
RBO: Rule-based optimizer, with indexes using indexes.Then all tables with indexes will go through the index in any case
Second, the values and parameters of the execution plan
Code
explain(select * from t_users id=1unionselect * from t_users id=2);Running Results
- select_type: category, mainly used to distinguish complex queries (union) such as ordinary queries, union queries, sub-queries, etc.
simple: a simple select query without subqueries or unions
primary: The query contains any complex subparts, the outermost query is marked
derived: The subquery is used in the from list, the table is used as the query condition, and the subquery is also calculated
union: Included in the subquery of the from clause, a temporary table will be generated when the subquery occurs
- paritiions: If the table data volume is large, set the partition conditions.
- possible_keys: possible keys (indexes)
- key: the index actually used
- key_len: length of key used (bytes)
- ref: Shows which field or constant is used with the key
- rows: how much data to traverse to find
- type: is a more important indicator, the result value is (performance) in order from best to worst
system > const > eq_ref > ref > fulltext > ref_or_null > index_merge > index_subquery > range > index > allNote: (marked in red means that the system has gone to the index)
system: There is only one row in the table (equal to the system table);
const means that it is found once by index;
eq_ref: one-dimensional record;
ref: non-unique index scan;
range: retrieve only rows in a given range
all: full table scan
index: index coverage (scan all)
null: execute without even accessing the table or index;
- Extra: Indicates important extra information that doesn't fit in other columns
Using index: Covering the index to avoid accessing the table.
Using temporary: sorting temporary table
Using where: filter after retrieval
How to optimize the performance of myql?
The server checks the query cache first, and if it hits the cache, it immediately returns the result stored in the cache.Otherwise go to the next stage.
If a column is indexed, try to avoid using the null value, because its value is more complex and it is not easy to create an index.
边栏推荐
- ATM银行系统(对象初级练习)
- 303. Range Sum Query - Immutable
- websocket Handshake failed due to invalid Upgrade header
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
- sphinx error connection to 127.0.0.1:9312 failed (errno=0, msg=)
- ICDAR competition technology sharing
- JVM参数设置
- After using Stream for many years, does collect still have these "saucy operations"?
- 九种方法!教你如何读取resources目录下的文件路径
- 一些嵌入式软件设计经验
猜你喜欢

J9数字虚拟论:元宇宙的潜力:一股推动社会进步的力量

软件测试<用例篇>

数字资产的价值激发:NFT 质押

【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(十一)

使用.NET简单实现一个Redis的高性能克隆版(一)

一些嵌入式软件设计经验

Interpretation of the paper (JKnet) "Representation Learning on Graphs with Jumping Knowledge Networks"

PTA递归练习

Cool open technology x StarRocks: unified OLAP analysis engine, comprehensive building digital model of OTT

EMQX Newsletter 2022-07|EMQX 5.0 正式发布、EMQX Cloud 新增 2 个数据库集成
随机推荐
一加Ace值得买吗?用实力诠释性能的强大
Big guys.Use flink-cdc-sqlserver version 2.2.0 to read sqlserver2008R
【engine】RtcSyncCallback回调、回调容器RtcCallbackContainer及MediaPacketSenderImpl 中回调使用
LyScript 从文本中读写ShellCode
“68道 Redis+168道 MySQL”精品面试题(带解析),你背废了吗?
“vite”和“vite预览”有什么区别?
【技术白皮书】第二章:OCR智能文字识别回顾——自然语言文本发展历程
软考 --- 软件工程(1)概念、开发模型
CC2530_ZigBee+华为云IOT:设计一套属于自己的冷链采集系统
【GAMES101】作业6 加速结构
【目标检测】Focal Loss for Dense Object Detection
星巴克输血赶不上流血
After using Stream for many years, does collect still have these "saucy operations"?
isNotBlank与isNotEmpty
sibling component communication context
高效的组织信息共享知识库是一种宝贵的资源
Map和Set
node connection mongoose database process
003_Kubernetes核心技术
新“妖股”13个交易日暴涨320倍,市值3100亿美元超阿里

