当前位置:网站首页>How to optimize MySQL
How to optimize MySQL
2022-07-27 03:26:00 【Hide on jdk】

Now there is 3000W Left and right data , Perform the following tests .
1. According to the leftmost matching principle , Do not use in the first index column >
, It must be a full meter scan

2. Coverage index optimization : How to optimize the above situation ?

3.in and or When the amount of table data is large, the index will be used , When there are few table records, full table scanning will be selected
3000W Your watch didn't go through the full scan , go Range


Only 5 Bar record : The efficiency of walking full table scanning is higher than that of walking index

Index push down (Index Condition Pushdown,ICP)
effect : Index push down will reduce the number of table returns
SELECT * FROM employees WHERE name like 'LiLei%'AND age = 22 AND position ='manager'
Pushing forward without index : First query like And then return to the table , Finally, according to the results of the back table age and position Compare , Efficiency and efficiency
There is the practice of pushing down the index : First like and age,position Compare together as a condition , Then go back to the table , It can effectively reduce the times of returning to the table
As follows :
Why? >a Walk the whole watch ,>zzz Search by range ?


trace Tools to analyze execution costs . It is found that the time of full table scanning is less than that of indexing , Gu Zou full table scanning
order by The optimization of the :
Look at the first situation : key_len=74, Only name The index is gone ,position No index ,extra=Using index condition, It means that it is still sorted in memory , Not disk sort

The situation is the same as above ,key_len=78
Look at this situation : Do not follow the leftmost match , therefore using filesort, File sorting

Do not follow the leftmost match, but also follow the file sorting

Look at this situation : The ascending and descending order is inconsistent , Also go through file sorting
One way two-way sorting :
Using filesort Detailed explanation of document sorting principle
filesort Sort files
One way sorting : Is to retrieve all fields of the qualified row at one time , And then in sort buffer In order
Two way sorting ( Also called table sorting mode ): First, the corresponding sorting fields and rows can be directly located according to the corresponding conditions
Lines of data ID, And then in sort buffer In order , After sorting, you need to retrieve other required fields again ;
Determine which sort mode to use .
If The total length of the field is less than max_length_for_sort_data , So use One way sort mode ;
If The total length of the field is greater than max_length_for_sort_data , So use Two way sorting module ∙ type .
边栏推荐
猜你喜欢

MySQL:互联网公司常用分库分表方案汇总

Plato farm has a new way of playing, and the arbitrage eplato has secured super high returns

Spark Learning Notes (V) -- spark core core programming RDD conversion operator

Boom 3D new 2022 audio enhancement app

周全的照护 解析LYRIQ锐歌电池安全设计

太强了,一个注解搞定接口返回数据脱敏

带你了解什么是 Web3.0

延时队列的几种实现姿势?日常必备技能!

mysql底层数据结构

DTS搭载全新自研内核,突破两地三中心架构的关键技术|腾讯云数据库
随机推荐
Code practice when the queue reaches the maximum length
MySQL的数据库有关操作
[learning notes, dog learning C] string + memory function
架构基本概念和架构本质
Does Oracle have a distributed database?
【flask】服务端获取客户端的请求头信息
redis秒杀案例,跟着b站尚硅谷老师学习
What are "full five unique" and "full two unique"? Any difference?
Data Lake (20): Flink is compatible with iceberg, which is currently insufficient, and iceberg is compared with Hudi
Data Lake (20): Flink is compatible with iceberg, which is currently insufficient, and iceberg is compared with Hudi
volatile关键字及其作用
Wechat applet generation Excel
30 minutes to thoroughly understand the synchronized lock upgrade process
渗透测试-后渗透-痕迹清理
It's too strong. An annotation handles the data desensitization returned by the interface
Detailed explanation of const usage in C language
Docker creates MySQL 8.x container and supports Mac and arm architecture chips
Common events of window objects
延时队列的几种实现姿势?日常必备技能!
[understanding of opportunity -52]: the depth of communication varies from person to person