当前位置:网站首页>Is the number of indexes in a table the more the better?
Is the number of indexes in a table the more the better?
2022-06-25 06:27:00 【JavaEdge.】
Go to InnoDB When adding data to the table , The cluster index will be automatically established based on the primary key . As we keep inserting data into the table , Will keep inserting data into the data page . When a data page is full , It will split into multiple data pages , At this time, the index page is needed to point to each data page .
If there are too many data pages , Then there will be too many data page pointers in the index page , The index page is bound to be full , So the index page will split , Then form a higher index page .
Default MySQL The cluster indexes established are organized based on the value of the primary key , The leaf nodes of cluster index are all data pages , Inside is the inserted row of complete data .
- Data pages / The records in the index page form a one-way linked list , Ordered by data size
- Data pages / Index pages form a two-way linked list with each other , They are also arranged in order according to the size of the data
therefore B+ An index tree is a completely ordered data structure , Whether inside or between pages , This allows you to find data , Start directly from the root node and look down layer by layer according to the size of the data value , It's very efficient .
MySQL Create indexes corresponding to some fields in the table of , What's good about it ?
It can be directly based on the index of a field B+ Tree to find data , No need for full table search , High performance improvement . But there are downsides :
Space
Every B+ Trees take up a lot of disk space , Too many indexes , It takes a lot of disk space .
Do a lot of indexing , When adding, deleting, modifying and checking , Maintain the data order of each index every time , Because every index B+ Trees require that pages be sorted by value size , Pages are also ordered :
Next One individual page Of the Yes value have to Must be > On One individual page Of the Yes value All values on the next page must be > All values of the previous page Next One individual page Of the Yes value have to Must be > On One individual page Of the Yes value
So keep adding, deleting, modifying and checking , It will inevitably lead to the value size between various data pages may be out of order , For example, a smaller value is inserted in the next data page , It's smaller than the value of the previous data page ! At this time, there is no way , Only data pages can be moved , Maintain the order between pages .
Time
Keep inserting data , The data pages of each index keep splitting , Keep adding new index pages , This process is time-consuming .
So if you have too many indexes in a table , It is likely to lead to the poor speed of your addition, deletion and modification , Maybe the query speed can be improved , But the addition, deletion and modification will be affected , Therefore, it is not recommended to have too many indexes in a table !
边栏推荐
- 2022-02-19: fence installation. In a two-dimensional garden, there are some trees represented by (x, y) coordinates. As the installation cost is very expensive, your task is to enclose all the trees w
- How two hosts in different network segments directly connected communicate
- 2022 AI trend 8 forecast!
- Personal blog system graduation project opening report
- Which of the top ten securities companies has the lowest Commission and is the most safe and reliable? Do you know anything
- RT thread i/o device model and layering
- Go uses channel to control concurrency
- Why study discrete mathematics
- Detailed explanation of @jsoninclude annotation in Jackson
- Understanding the dynamic mode of mongodb document
猜你喜欢

ARM processor operating mode

The five minute demonstration "teaches" actors to speak foreign languages and can seamlessly switch languages. This AI dubbing company has just received a round a financing of 20million US dollars

Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things

JS dynamic table creation

IQ debugging of Hisilicon platform ISP and image (1)

Gb28181 protocol -- timing

C simple operation mongodb

What elements are indispensable for the development of the character? What are the stages
![[short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]](/img/4a/304f262c1c08800aa95f9e2d537e4d.jpg)
[short time average zero crossing rate] short time average zero crossing rate of speech signal based on MATLAB [including Matlab source code 1721]

Understanding the dynamic mode of mongodb document
随机推荐
PHP and WMI – explore windows with PHP
Guess the size of the number
Analysis report on production and sales demand and sales prospect of global and Chinese phosphating solution Market 2022-2028
ARM processor operating mode
Arm instructions and others
Exercise: completion
China rehabilitation hospital industry operation benefit analysis and operation situation investigation report 2022
[v2.0] automatic update system based on motion step API (support disconnection reconnection and data compensation)
Cannot activate inspection type when SAP retail uses transaction code mm41 to create commodity master data?
Metauniverse in 2022: robbing people, burning money and breaking through the experience boundary
Arm register (cortex-a), coprocessor and pipeline
How to use asemi FET 7n80 and how to use 7n80
Noi Mathematics: Dirichlet convolution
Ifconfig command – displays or sets network devices
Brief introduction and use of JSON
Understand what MTU is
[Suanli network] problems and challenges faced by the development of Suanli network
How to deploy locally developed SAP ui5 applications to ABAP servers
Lesson 9: workspace introduction
Methods for obtaining some information of equipment