当前位置:网站首页>Self adjustment process of MySQL index tree when adding data
Self adjustment process of MySQL index tree when adding data
2022-06-25 06:27:00 【JavaEdge.】
At first, after you build a watch , Just one data page , Is part of the clustered index , And it's empty . If you insert data , Is to insert... Directly into this data page , There's no need to get him an index page :

The initial data page is a root page , Each data page has a page directory based on the primary key by default , So it's OK to search according to the primary key , Directly find... In the only data page according to the page directory .
But with more and more data in the table , Your data page is full , A new data page is needed , Copy all the data in your root page , At the same time, make a new data page , Move according to the size of your primary key value , Let two new data pages sort according to the primary key value , The primary key value of the second data page is greater than that of the first data page :

At this point, the root page is upgraded to the index page , In this root page :
Page number of two data pages
The smallest primary key value in them
So it seems that the root page becomes the index page , Two data pages are referenced .

As you keep plugging in data , Then the data page keeps splitting , Split up more data pages . Your only index page , That is, there are more and more data page index entries stored in the root page , I can't even fit your index page , Then split an index page into two index pages , Then the root page continues to go up one level , Reference two index pages .
More and more data pages , The index page that the root page points to keeps splitting , Split more index pages , When you have too many index pages in the lower layer , It will cause your root page to point to too many index pages , The root page continues to split into multiple index pages , The root page moves up one level again . This is when you add, delete and modify , The whole process of cluster index maintenance .
Secondary indexes
Empathy , Like you name Field has an index , So at the beginning, you insert data , On the one hand, insert... In the unique data page of the cluster index , On the one hand name Index of field B+ Insert... Into the only data page of the tree .
With more and more follow-up data ,name The only data page in the index tree will also split , The whole process of division is the same as above , So when you insert data , The index tree itself will be maintained automatically .
Yours name Index of field B+ In the index page in the tree , In fact, in addition to storing the page number and the smallest name Other than field value , Each index page will also store the smallest name The primary key value corresponding to the field value . Because sometimes there will be the smallest number of the lower page pointed to by multiple index pages name Field values are the same , You have to judge according to the primary key .
For example, insert a new name value , He needs to be based on name The root page of the index tree starts , Find your new... Layer by layer name Which data page the value should be inserted into the leaf node .
In case of different index pages in the same layer pointing to different lower page numbers , but name Have the same value , You have to compare according to the primary key value : new name The value is inserted into the data page with a larger primary key value !
边栏推荐
- Global and Chinese medical protective clothing market supply and demand research and investment value proposal report 2022-2028
- Hands on deep learning (III)
- Tablespace free space
- Sleep quality today 67 points
- Understand what ICMP Protocol is
- Mongodb delete data
- Handling skills of SQL optimization (2)
- Which of the top ten securities companies has the lowest Commission and is the most safe and reliable? Do you know anything
- Find command – find and search for files
- Research Report on investment share and application prospect of 1,3-propanediol (PDO) industry in the world and China 2022
猜你喜欢

Introduction to sap ui5 tools

SAP QM executes the transaction code qp01, and the system reports an error -material type food is not defined for task list type Q-

2022 AI trend 8 forecast!

Gb28181 protocol -- timing

Drosophila played VR and entered nature. It was found that there were attention mechanisms and working memory. The insect brain was no worse than that of mammals
![[speech discrimination] discrimination of speech signals based on MATLAB double threshold method [including Matlab source code 1720]](/img/36/ad86f403b47731670879f01299b416.jpg)
[speech discrimination] discrimination of speech signals based on MATLAB double threshold method [including Matlab source code 1720]

VMware virtual machine prompt: the virtual device ide1:0 cannot be connected because there is no corresponding device on the host.

Guess the size of the number

JS to determine whether an element exists in the array (four methods)

Pre knowledge of asynchronous operation
随机推荐
MV command – move or rename files
[short time energy] short time energy of speech signal based on MATLAB [including Matlab source code 1719]
Uncaught typeerror cannot set properties of undefined (setting 'classname') reported by binding onclick event in jsfor loop
The perfect presentation of Dao in the metauniverse, and platofarm creates a farm themed metauniverse
Cnpm installation
TFTP command – uploading and downloading files
SAP QM executes the transaction code qp01, and the system reports an error -material type food is not defined for task list type Q-
[Suanli network] technological innovation of Suanli Network -- Key Technologies of green and security
Leetcode sword finger offer question brushing - day 27
Fdisk command – disk partition
Record of friend guide
At the age of 26, I was transferred to software testing with zero foundation. Now I have successfully entered the job with a monthly salary of 12K. However, no one understands my bitterness
RT thread i/o device model and layering
Analysis report on investment and financing status and operation benefits of global and Chinese dental industry (2022 Edition)
Global and Chinese medical protective clothing market supply and demand research and investment value proposal report 2022-2028
How to chain multiple different InputStreams into one InputStream
Gb28181 protocol -- timing
Wechat applet simply realizes chat room function
Handling skills of SQL optimization (2)
Lesson 9: workspace introduction