当前位置:网站首页>Detailed introduction to paging exploration of MySQL index optimization
Detailed introduction to paging exploration of MySQL index optimization
2022-04-23 11:06:00 【liming89】
Source of the article : Learn through http://www.bdgxy.com/
??MySQL?? Paging exploration of index optimization
Table structure
CREATE TABLE `demo` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT ' full name ',
`age` int(11) NOT NULL DEFAULT '0' COMMENT ' Age ',
`position` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT ' Position ',
`card_num` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT ' Job card No ',
PRIMARY KEY (`id`),
KEY `index_union` (`name`,`age`,`position`)
) ENGINE=InnoDB AUTO_INCREMENT=450003 DEFAULT CHARSET=utf8;
450003 Data
limit Paging execution

image select * from demo limit 90000,10; Considering the back table , therefore mysql Simply choose full table scanning .
mysql Not directly from the third party 90000 Line start calculation 10 strip , Instead, start counting from the first leaf node , Calculation 90010 That's ok .
Case a

For the above figure , When id It's a time of continuous self increase , You can use the primary key to filter out id=90000 Later data . Because the index of the primary key is B+ Tree structure , It's orderly .

Case 2

First according to name Sort , And then from the 90000 Line up to find 10 That's ok , although name It's the index , but select Of is listed in index_union There is no save in the index tree .
So it will also involve the back table , therefore mysql Directly select the leaf node of the primary key index tree , First the 40 According to name Arrange order well , And then calculate 90000 That's ok +10 That's ok .
An optimization method : Using sub query to solve the most time-consuming sorting and back to table problems , The joint index tree species have a primary key id,order by name If you can name、age、position The entire index is fully used because it determines the sort of the leftmost column , The other two columns age、 and position Actually, too.
It's in order , adopt Extra Fields can also be sorted using an index tree .
The outermost query is associated according to the primary key , So you can almost ignore .10+10 because id It's the primary key , You can take the temporary watch directly 10 Data to scan .

This is about MySQL That's all for the detailed introduction of paging exploration of index optimization , More about MySQL For pagination exploration content, please search rookie tutorial www.piaodoo.com Previous articles or continue to browse the relevant articles below. I hope you can support rookie tutorials in the future www.piaodoo.com!
版权声明
本文为[liming89]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231102124793.html
边栏推荐
- Typora operation skill description (I)
- 升级cpolar内网穿透能获得的功能
- 比深度学习更值得信赖的模型ART
- Promise详解
- About the three commonly used auxiliary classes of JUC
- Analysis on the characteristics of the official game economic model launched by platoffarm
- Microsoft Access database using PHP PDO ODBC sample
- 最强日期正则表达式
- How to use JDBC callablestatement The wasnull () method is called to check whether the value of the last out parameter is SQL null
- colab
猜你喜欢

Excel · VBA array bubble sorting function

MySQL Router重装后重新连接集群进行引导出现的——此主机中之前已配置过的问题

How to quickly download vscode

第六站神京门户-------手机号码的转换

Introduction to data analysis 𞓜 kaggle Titanic mission (III) - > explore data analysis

Learning Notes 6 - Summary of several deep learning convolutional neural networks

Visualization Road (10) detailed explanation of segmentation canvas function

Visualized common drawing (II) line chart

ID number verification system based on visual structure - Raspberry implementation

Mysql8.0安装指南
随机推荐
详解MySQL中timestamp和datetime时区问题导致做DTS遇到的坑
MySQL数据库事务transaction示例讲解教程
The songbird document editor will be open source: starting with but not limited to markdown
After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
Three web components (servlet, filter, listener)
Microsoft Access database using PHP PDO ODBC sample
GO接口使用
Notes on concurrent programming of vegetables (V) thread safety and lock solution
Constraintlayout layout
MySQL索引优化之分页探索详细介绍
mysql创建存储过程及函数详解
Excel·VBA数组冒泡排序函数
Google Earth Engine(GEE)——将原始影像进行升尺度计算(以海南市为例)
Software testers, how to mention bugs?
MIT:用无监督为世界上每个像素都打上标签!人类:再也不用为1小时视频花800个小时了
Use of SVN:
Detailed explanation of typora Grammar (I)
The difference between restful and soap
Solution architect's small bag - 5 types of architecture diagrams
学习 Go 语言 0x04:《Go 语言之旅》中切片的练习题代码