当前位置:网站首页>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
边栏推荐
- UDP basic learning
- Alarm scene recognition
- Pytorch implementation of transformer
- MIT:用无监督为世界上每个像素都打上标签!人类:再也不用为1小时视频花800个小时了
- Use of SVN:
- Excel · VBA custom function to obtain multiple cell values
- MBA-day5數學-應用題-工程問題
- Mba-day5 Mathematics - application problems - engineering problems
- Gets the current time in character format
- Software testers, how to mention bugs?
猜你喜欢

Introduction to neo4j authoritative guide, recommended by Qiu Bojun, Zhou Hongxiang, Hu Xiaofeng, Zhou Tao and other celebrities

Detailed explanation of typora Grammar (I)

More reliable model art than deep learning

Excel·VBA数组冒泡排序函数

一道有趣的阿里面试题

Excel·VBA自定义函数获取单元格多数值

Notes on concurrent programming of vegetables (V) thread safety and lock solution

Jupyter lab top ten high productivity plug-ins

语雀文档编辑器将开源:始于但不止于Markdown

Manjaro installation and configuration (vscode, wechat, beautification, input method)
随机推荐
The courses bought at a high price are open! PHPer data sharing
FileProvider 路径配置策略的理解
Difference between pregnancy box and delivery box
An interesting interview question
Derivation and regularization
MBA - day5 mathématiques - Questions d'application - Questions d'ingénierie
RESTful和SOAP的区别
MySQL面试题讲解之如何设置Hash索引
Mba-day5 Mathematics - application problems - engineering problems
我的创作纪念日
Source insight 4.0 FAQs
学习 Go 语言 0x08:《Go 语言之旅》中 练习使用 error
MySQL对数据表已有表进行分区表的实现
The songbird document editor will be open source: starting with but not limited to markdown
Common parameters of ffmpeg command line
Is the pointer symbol of C language close to variable type or variable name?
Resolution and size of mainstream mobile phones
软件测试人员,如何优秀的提Bug?
CUMCM 2021-B:乙醇偶合制備C4烯烴(2)
SVN的使用: