当前位置:网站首页>MySQL index - extended data
MySQL index - extended data
2022-07-05 12:13:00 【ziyi813】
MySQL Indexes - Extended data
Overview of indexing principle
The index is stored on disk as a file , Disk error will occur during index lookup I/O Consume , Relative to memory search ,I/O The consumption is several orders of magnitude higher , The most important index to judge whether a data structure is good or bad as an index is the disk in the search process I/O Progressive complexity of the number of operations .
The index structure should be organized to minimize the disk in the search process I/O Consume .
Related algorithms
Hash Algorithm
advantage : Through the value The value is calculated by a specific function hash value , according to hash Value to get data location data information , Location data is very fast .
shortcoming : Can't do range lookup , because hash Is chaotic , Cannot make size comparison .
Indexes | hash function | Hash value | data |
---|---|---|---|
20 | 20 -> fn(20) -> 0x11 | 0x11 | (20, litchi , 18) |
40 | 40 -> fn(40) -> 0x12 | 0x12 | (40, watermelon , 28) |
Suitable for locating and searching single line data , Not suitable for range finding .
BTREE Trees
B-Tree,B+Tree
On-line Btree Tree data structure visualization website , Here you can see that the data structure can be viewed by yourself Btree The modeling process of tree structure
https://www.cs.usfca.edu/~galles/visualization/Algorithms.html
https://www.cs.usfca.edu/~galles/visualization/BPlusTree.html
MyISAM Engine USES B+Tree
Leaf node data The domain stores the address of the data record ,( The pointer ).
InnoDB Engine USES B+Tree
Leaf node data Fields store real data , therefore innoDb The index of takes up a lot of hard disk storage space .
Features of index
The advantages of indexing
Speed up data query
When using grouping or sorting for data query , It can significantly reduce the query time
Create unique index , Ensure the uniqueness of each row of data in the database table
Disadvantages of indexes
- Creating and maintaining indexes takes time , And the increase of random data , Time will also increase
- The index takes up disk space , The bigger the data , The larger the disk used
- Add the data in the data table , modify , When deleting , Indexes also need to be maintained dynamically , Increase the performance consumption of the server
The principle of index creation
- Columns that update frequently should not be indexed
- Don't use indexes for tables with small amount of data
- The index should not be set for fields with many duplicate data ( Like gender : Only men and women , Generally speaking , More than... Percent of the data is duplicated 15 You shouldn't index )
- First of all, we should consider where and order by Index the columns involved
边栏推荐
- pytorch-权重衰退(weight decay)和丢弃法(dropout)
- 只是巧合?苹果 iOS16 的神秘技术竟然与中国企业 5 年前产品一致!
- Why learn harmonyos and how to get started quickly?
- 无线WIFI学习型8路发射遥控模块
- 【L1、L2、smooth L1三类损失函数】
- Matlab imoverlay function (burn binary mask into two-dimensional image)
- [mainstream nivida graphics card deep learning / reinforcement learning /ai computing power summary]
- Video networkState 属性
- MySQL constraints
- 信息服务器怎么恢复,服务器数据恢复怎么弄[通俗易懂]
猜你喜欢
Riddle 1
Troubleshooting of high memory usage of redis in a production environment
你做自动化测试为什么总是失败?
[upsampling method opencv interpolation]
报错ModuleNotFoundError: No module named ‘cv2.aruco‘
16 channel water lamp experiment based on Proteus (assembly language)
liunx禁ping 详解traceroute的不同用法
无线WIFI学习型8路发射遥控模块
Matlab label2idx function (convert the label matrix into a cell array with linear index)
Check the debug port information in rancher and do idea remote JVM debug
随机推荐
July Huaqing learning-1
Swift - add navigation bar
调查显示传统数据安全工具在60%情况下无法抵御勒索软件攻击
Two minutes will take you to quickly master the project structure, resources, dependencies and localization of flutter
2022年国内云管平台厂商哪家好?为什么?
查看rancher中debug端口信息,并做IDEA Remote Jvm Debug
Codeworks 5 questions per day (1700 average) - day 5
mmclassification 训练自定义数据
Codeforces Round #804 (Div. 2)
pytorch-多层感知机MLP
Select drop-down box realizes three-level linkage of provinces and cities in China
【yolov3损失函数】
一类恒等式的应用(范德蒙德卷积与超几何函数)
One article tells the latest and complete learning materials of flutter
只是巧合?苹果 iOS16 的神秘技术竟然与中国企业 5 年前产品一致!
Matlab label2idx function (convert the label matrix into a cell array with linear index)
【ijkplayer】when i compile file “compile-ffmpeg.sh“ ,it show error “No such file or directory“.
How can beginners learn flutter efficiently?
【TFLite, ONNX, CoreML, TensorRT Export】
7月华清学习-1