当前位置:网站首页>[MySQL learning notes 22] index
[MySQL learning notes 22] index
2022-06-25 09:38:00 【yqs_ two hundred and eighty-one million eight hundred and seven】
Advantages and disadvantages
| advantage | Inferiority |
|---|---|
| Improve the efficiency of data retrieval , Reduce the io cost | The index column takes up space |
| Sort data by indexing Columns , Reduce the cost of sorting data , Reduce CPU Consumption of | Indexing greatly improves query efficiency , It also reduces the efficiency of updating tables , Because you need to update the index while updating the table |
Index structure
| Index structure | describe |
|---|---|
| B+Tree Indexes ( Default ) | The most common type of index , Most engines support |
| Hash Indexes | The underlying principle is the hash table , Range query is not supported , Can only match exactly |
| R-Tree | Commonly used for geospatial data types |
| Full-text( Full-text index ) | It's a way of building inverted indexes , How to quickly match documents |
Each engine supports indexing

Index classification
| classification | meaning | characteristic | keyword |
|---|---|---|---|
| primary key | The index created for the primary key in the table | Automatically created by default , There can only be one | PRIMARY |
| unique index | Avoid a column with duplicate values | There can be multiple | UNIQUE, You can specify when creating a table , It can also be added manually later |
| General index | Quickly locate data | There can be multiple | nothing , You need to create... Manually |
| Full-text index | Fast Text Retrieval | There can be multiple | FULLTEXT |
expand : The uniqueness of column value depends on the unique index .
| classification | meaning | characteristic |
|---|---|---|
| Clustered index | Put data storage and storage together , The leaf node of the index structure holds the row data | There has to be , And there is only one , When creating a table, the primary key is automatically used as a clustered index , If there is no primary key , Use the first unique index as the clustered index , If not ,InnoDB Will automatically a hidden rowid As a clustered index |
| Secondary indexes | Separate data from index , The leaf node of the index structure stores the corresponding primary key | There can be multiple |
example

Such as execution select * from user where name =‘Arm’;
Then we'll go first name Search in the index Arm, Query to Arm The corresponding id yes 10, Then I'll take this 10 Go to the clustered index to find specific data , Then return . This process is called “ Return to the table for query ”.
Create index
create [unique|fulltext] index index_name on table_name (index_col_name1,…);
Look at the index
show index from table_name;
Delete index
drop index index_name on table_name;
边栏推荐
- [IOU] intersection over union
- 可穿戴设备或将会泄露个人隐私
- How much money have I made by sticking to fixed investment for 3 years?
- PMP考试多少分算通过?
- Is it safe to open an account on the compass?
- Lvs-dr mode single network segment case
- Flutter multilingual intl: ^0.17.0 cannot be imported
- SQL高级
- Voiceprint Technology (III): voiceprint recognition technology
- Question B of the East China Cup: how to establish a population immune barrier against novel coronavirus?
猜你喜欢

Matplotlib simple logistic regression visualization
![[competition - Rural Revitalization] experience sharing of Zhejiang Rural Revitalization creative competition](/img/b4/84c30ed112c4dffd8d51697b2f4a4f.jpg)
[competition - Rural Revitalization] experience sharing of Zhejiang Rural Revitalization creative competition

Cassava tree disease recognition based on vgg16 image classification

瑞萨RA系列-开发环境搭建

Wallys/MULTI-FUNCTION IPQ6010 (IPQ6018 FAMILY) EMBEDDED BOARD WITH ON-BOARD WIFI DUAL BAND DUAL
![[buuctf.reverse] 117-120](/img/6c/8a90fff2bd46f1494a9bd9c77eeafc.png)
[buuctf.reverse] 117-120

Compare and explain common i/o models

Cubemx stm32f105rb USB flash drive reading and writing detailed tutorial

matplotlib matplotlib中plt.axis()用法

Compile time annotations for custom annotations (retentionpolicy.class)
随机推荐
The first techo day Tencent technology open day, 628 waiting for you!
[matlab] image binarization (imbinarize function)
pmp考试题型需要注意哪些?
Data-driven anomaly detection and early warning of 21 May Day C
Benefits and types of cloud network technology
x86的编码格式
Socket programming -- epoll model
Opencv中的GrabCut图像分割
富时A50开户什么地方安全
Match a mobile number from a large number of mobile numbers
Abbreviations of common English terms for IC R & D
Voiceprint Technology (VII): the future of voiceprint Technology
测试开发工程师
Voiceprint Technology (I): the past and present life of voiceprint Technology
TLAB mechanism of JVM object memory allocation and TLAB process in G1
Why should the terminal retail industry choose the member management system
35 websites ICER must know
CSV parameterization in JMeter
The meshgrid() function in numpy
Use Navicat to compare data differences and structure differences of multi environment databases, and automatic DML and DDL scripts