当前位置:网站首页>[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;
边栏推荐
- vscode试图过程写入管道不存在
- STM32 receives data by using idle interrupt of serial port
- Analysis on the thinking of 2022 meisai C question
- C语言刷题随记 —— 猴子吃桃
- Flutter multilingual intl: ^0.17.0 cannot be imported
- Huipay international permet au commerce électronique transfrontalier de devenir une plate - forme de paiement transfrontalière conforme!
- Simple waterfall effect
- Work of the 15th week
- SQL advanced
- Voiceprint Technology (VI): other applications of voiceprint Technology
猜你喜欢
汇付国际为跨境电商赋能:做合规的跨境支付平台!
vscode试图过程写入管道不存在
微服务调用组件Ribbon底层调用流程分析
Remittance international empowers cross-border e-commerce: to be a compliant cross-border payment platform!
Question B of the East China Cup: how to establish a population immune barrier against novel coronavirus?
Lvs-dr mode single network segment case
[zufe expense reimbursement] zhecai invoice reimbursement specification (taking Xinmiao reimbursement as an example), which can be passed in one trip at most
[zufe school competition] difficulty classification and competition suggestions of common competitions in the school (taking Zhejiang University of Finance and economics as an example)
Wechat official account can reply messages normally, but it still prompts that the service provided by the official account has failed. Please try again later
[wechat applet full stack development course] course directory (mpvue+koa2+mysql)
随机推荐
Voiceprint Technology (I): the past and present life of voiceprint Technology
Online notes on Mathematics for postgraduate entrance examination (9): a series of courses on probability theory and mathematical statistics
[design completion - opening report] zufeinfo 2018 software engineering major (including FAQ)
【mysql学习笔记20】mysql体系结构
可穿戴设备或将会泄露个人隐私
manhattan_slam环境配置
Voiceprint Technology (VII): the future of voiceprint Technology
STM32 receives data by using idle interrupt of serial port
Applet cloud development joint table data query and application in cloud function
Matplotlib decision boundary drawing function plot in Matplotlib_ decision_ Boundary and plt Detailed explanation of contour function
How do dating applets make millions a year? What is the profit model?
[buuctf.reverse] 121-125
Flitter gets the height of the top status bar
力扣-104. 二叉树的最大深度
[IOU] intersection over union
SQL advanced
Is it safe to open an account on the compass?
pmp考试题型需要注意哪些?
Remittance international empowers cross-border e-commerce: to be a compliant cross-border payment platform!
Solution to the problem of repeated startup of esp8266