当前位置:网站首页>MySQL index (easy to handle in one article)
MySQL index (easy to handle in one article)
2022-06-12 07:21:00 【Cool as the wind, wild as a dog】
Catalog
Index advantages and disadvantages
Index is help MySQL Efficient access to data Of data structure ( Orderly ). Out of data , The database system also maintains a data structure that satisfies a specific search algorithm , These data structures are referenced in some way ( Point to ) data , In this way, advanced query algorithms can be implemented on these data structures , This data structure is the index .

Index advantages and disadvantages
advantage :
- Improve the efficiency of data retrieval , Reduce the IO cost
- Sort data through index columns , Reduce the cost of sorting data , Reduce CPU Consumption of
shortcoming :
- Index columns also take up space
- Indexing greatly improves query efficiency , But it reduces the speed of update , such as INSERT、UPDATE、DELETE
Index structure


B-Tree

The disadvantage of binary tree can be solved by red black tree :

Red and black trees also have a large amount of data , Deeper levels , The problem of slow retrieval speed .
In order to solve the above problems , have access to B-Tree structure .
B-Tree ( Multiway balanced search tree ) At a maximum degree (max-degree, Refers to the number of child nodes of a node ) by 5(5 rank ) Of b-tree For example ( Each node can store up to 4 individual key,5 A pointer to the )

Demo address :B-Tree Visualization
https://www.cs.usfca.edu/~galles/visualization/BTree.html
B+Tree
chart :

Demo address :B+ Tree Visualization
https://www.cs.usfca.edu/~galles/visualization/BPlusTree.html
And B-Tree The difference between :
- All the data will appear in the leaf node
- Leaf nodes form a one-way linked list
MySQL Index data structure for classic B+Tree optimized . In the original B+Tree On the basis of , Add a pointer to the linked list of adjacent leaf nodes , So we have a sequence pointer B+Tree, Improve the performance of interval access .

Hash
Hash index is to use a certain hash Algorithm , Convert key values to new hash value , Map to the corresponding slot , Then stored in hash In the table .
If two ( Or more ) Key value , Map to the same slot , They produced hash Conflict ( Also known as hash Collision ), It can be solved by linked list .

characteristic :
- Hash Indexes can only be used for peer-to-peer comparisons (=、in), Range query is not supported (betwwn、>、<、...)
- Cannot complete sort operation with index
- High query efficiency , Usually only one search is needed , Efficiency is usually higher than B+Tree Indexes
Storage engine support :
- Memory
- InnoDB: It has adaptive function hash function ,hash The index is the storage engine B+Tree The index is automatically built under specified conditions
Interview questions
- Why? InnoDB The storage engine chooses to use B+Tree Index structure ?
- Relative to a binary tree , Fewer levels , High search efficiency
- about B-Tree, Whether leaf nodes or non leaf nodes , Data will be saved , This results in fewer key values stored in a page , The pointer decreases as well , Save a lot of data as well , Can only increase the height of the tree , Resulting in reduced performance
- be relative to Hash Indexes ,B+Tree Support range matching and sorting operations
边栏推荐
- FCPX插件:简约线条呼出文字标题介绍动画Call Outs With Photo Placeholders for FCPX
- Explain ADC in stm32
- i. Mx6ul porting openwrt
- Detailed explanation of 8086/8088 system bus (sequence analysis + bus related knowledge)
- node:打不开/node:已拒绝访问
- Demonstrate "topic communication, action communication, service communication and parameter server" with a small turtle case
- [image denoising] salt and pepper noise image denoising based on Gaussian filter, mean filter, median filter and bilateral filter with matlab code attached
- modelarts二
- Learning to continuously learn paper notes + code interpretation
- How to update kubernetes certificates
猜你喜欢

Postman splice replacement parameter loop call interface

Paddepaddl 28 supports the implementation of GHM loss, a gradient balancing mechanism for arbitrary dimensional data (supports ignore\u index, class\u weight, back propagation training, and multi clas

9 Sequence container

RT thread studio learning (IX) TF Card File System

Detailed explanation of memory addressing in 8086 real address mode

Kali与编程:如何快速搭建OWASP网站安全实验靶场?

Lambda function perfect use guide

Set up a remote Jupiter notebook

LED lighting experiment with simulation software proteus

2022年危险化学品经营单位安全管理人员特种作业证考试题库及答案
随机推荐
Set up a remote Jupiter notebook
knife4j 初次使用
企业微信官方 加解密库 PHP7版本报错 mcrypt_module_open 未定义方法 并且被PHP抛弃 解决方法使用 openssl解决
libprint2
9 Sequence container
There is no solid line connection between many devices in Proteus circuit simulation design diagram. How are they realized?
右击文件转圈卡住、刷新、白屏、闪退、桌面崩溃的通用解决方法
The function of C language string Terminator
Decoupling in D
"I was laid off by a big factory"
Qt实现托盘
C language sizeof strlen
LED lighting experiment with simulation software proteus
Adaptive personalized federated learning paper interpretation + code analysis
D
Esp8266 firmware upgrade method (esp8266-01s module)
New knowledge: monkey improved app crawler
五、EL 表达式& JSTL 标签库
openwrt uci c api
Thoroughly understand the "rotation matrix / Euler angle / quaternion" and let you experience the beauty of three-dimensional rotation