当前位置:网站首页>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
边栏推荐
- Chapter 1 of technical Xiaobai (express yourself)
- Code implementation of general bubbling, selection, insertion, hill and quick sorting
- 学习 Go 语言 0x08:《Go 语言之旅》中 练习使用 error
- Simple thoughts on the design of a microblog database
- MBA-day5数学-应用题-工程问题
- 学习 Go 语言 0x06:《Go 语言之旅》中 斐波纳契闭包 练习题代码
- Visual Road (XII) detailed explanation of collection class
- SWAT - Introduction to Samba web management tool
- Special members and magic methods
- Solution architect's small bag - 5 types of architecture diagrams
猜你喜欢
After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
关于JUC三大常用辅助类
第六站神京门户-------手机号码的转换
Solutions to common problems in visualization (IX) background color
Mysql8.0安装指南
Notes on concurrent programming of vegetables (V) thread safety and lock solution
Reading integrity monitoring techniques for vision navigation systems - 5 Results
学习 Go 语言 0x04:《Go 语言之旅》中切片的练习题代码
Let the LAN group use the remote device
UEditor之——图片上传组件大小4M的限制
随机推荐
学习网站资料
MBA-day5数学-应用题-工程问题
Chapter 1 of technical Xiaobai (express yourself)
主流手机分辨率与尺寸
Excel·VBA数组冒泡排序函数
Microsoft Access database using PHP PDO ODBC sample
MIT:用无监督为世界上每个像素都打上标签!人类:再也不用为1小时视频花800个小时了
Visualization Road (10) detailed explanation of segmentation canvas function
Solutions to common problems in visualization (VIII) solutions to problems in shared drawing area
SWAT - Introduction to Samba web management tool
MBA-day5數學-應用題-工程問題
Is the pointer symbol of C language close to variable type or variable name?
Facing the global market, platefarm today logs in to four major global platforms such as Huobi
PlatoFarm推出正式版游戏经济模型的特点分析
Data analysis learning (I) data analysis and numpy Foundation
Visual common drawing (IV) histogram
Notes on concurrent programming of vegetables (IX) asynchronous IO to realize concurrent crawler acceleration
The courses bought at a high price are open! PHPer data sharing
Restful、SOAP、RPC、SOA、微服务之间的区别
CUMCM 2021-b: preparation of C4 olefins by ethanol coupling (2)