当前位置:网站首页>Mysql-- index
Mysql-- index
2022-06-11 10:03:00 【Don't want to be a programmer】
Indexes : help MySQL Data structure for efficient data acquisition
Extract the sentence trunk , We can get the essence of index : An index is a data structure
Classification of indexes
- primary key (primary key): Unique identification , Do not repeat , There can only be One column A primary key
- unique index (unique key): Avoid duplicate columns , The unique index can be repeated , Multiple Columns can be identified as unique indexes
- General index (key/index): default ,index、key Keyword settings
- Full-text index (FullText): Only under the specific database engine ,MyISAM
Use of index
- Add indexes to fields when creating tables
- After creation , Add index
-- Show all index information
show index from student
-- Add a full text index
alter table student add fulltext index 'studentName';
-- explain analysis sql sentence
explain select * from student; -- Non full text index
-- Full text indexing is useless when there is a small amount of data
explain select * from student where match(studentName) against(' Liu ');-- Look up a piece of data
Test index
/* Insert a million pieces of data */
delimiter $$ /* Before you write a function, you have to write , sign */
create function mock_data()
returns int
begin
declare num int default 1000;
declare i int default 0;
while i<num do
/* Insert statement */
set i = i+1;
end while ;
return i;
end;

– Common naming methods for indexes :id_ Table name _ Field name
--create index Index name on surface ( Field )
create index id_app_user_name on app_user('name');
explain select * from app_user where name='iii';
Index in a small amount of data , Not many users , But when it comes to big data , The difference is obvious
Indexing principles
- More indexes is not better
- Don't index frequently changing data
- A table with a small amount of data does not need to be indexed
- The index is usually added to the fields commonly used for query
The data structure of the index
hash Index of type
Btree:InnoDB Default data structure
边栏推荐
- 等待事件 enq: KO - fast object checkpoint可行的一些处理方法
- 标配双安全气囊,长安Lumin上市,起价4.89万元
- ZigBee模块通信协议的树形拓扑组网结构
- Product list display
- Tap and longtap encapsulation of touch events -- from Ono
- Introduction to ZigBee module wireless transmission star topology networking structure
- 不同CV任务的标注类型
- Mysql比较
- [image denoising] image denoising based on median + wavelet + Wiener + filter, including Matlab source code
- What are the functions and applications of Mogg test controller
猜你喜欢

Mysql--索引

ORACLE RAC中连接ScanIP报错ORA-12545的问题解决

An error can't locate env pm in @INC

How to determine whether two time periods overlap?

The ins-30131 installer failed to verify the required initial settings

标配双安全气囊,长安Lumin上市,起价4.89万元

Beginning简约博客emlog主题模板V3

ORA-00059 超过db_files限制

关于马格齿轮泵的应用领域都有哪些?总结一下

鼠标点击坐标转换生成
随机推荐
General idea of interface tuning
What are the application fields of MAG gear pump? To sum up
With determination to forge ahead, JASMINER continues to deepen its brand strength
ZigBee模块通信协议的树形拓扑组网结构
[Clickhouse column] user initialization of new library role
【clickhouse专栏】新建库角色用户初始化
Beginning简约博客emlog主题模板V3
RSA签名问题
ESP8266_ Access to the core suite of Baidu Internet of things and use mqtt protocol for communication
UGUI
Interview review - closure
Image quality evaluation including Matlab source code
Override and reload?
Function and function of wandfluh proportional valve
WordPress website backup
B站到底能不能赚到钱?
面试复习之---闭包
Vk2c22a/b anti-interference series electric meter, water meter segment code LCD driver chip data (customized dice/cog)
[high concurrency] the interviewer of ant financial asked me about thread pool!!
Understanding polymorphism?