当前位置:网站首页>What is an index in MySql?What kinds of indexes are commonly used?When does an index fail?
What is an index in MySql?What kinds of indexes are commonly used?When does an index fail?
2022-08-09 16:14:00 【Ran959】
I. What is an index
In a relational database, an index is a storage structure that separates and physically sorts the values of one or more columns in a database table.A list of logical pointers to the data pages in the table that physically identify these values.The function of the index is equivalent to the directory of the book, which can quickly find the desired content according to the page number in the directory.
Index (index): like the directory of a book, used to speed up the search efficiency;
The role of index: speed up search efficiency. Slow down insertion and deletion, modification efficiency. (Need to adjust index results synchronously)
Second, common index types
1. Primary key index
The primary key is a unique index and must be specified as PRIMARY KEY (ie primary key)
alter table table name add primary key (`field name`);
2. Unique index
All values of the index column can only appear once (that is, must be unique), and the value can be null
alter table table name add primary key (`field name`);
3. Ordinary index
The basic index type, the value can be null, there is no unique constraint
alter table table name add index (`field name`);
4. Full-text index
The index of full-text index is FULLTEXT type.Full-text indexes can be created on columns of type varchar, char, and text.Can be created via ALTER TABLE or CREATE INDEX
alter table table name add FULLTEXT(`field name`);
Three, under what circumstances does the index fail
1.Improper use of the like query will cause the index to fail
Wildcard % at the beginning will cause the index to fail
select * from table name where field name like '%__';
2. The best left prefix rule
If there are multiple indexes in a table, the best left prefix rule should be followed, that is, the query starts from the leftmost front column of the index and does not skip the columns in the index.
3. The data types on both sides of the query condition are inconsistent
边栏推荐
猜你喜欢
随机推荐
量化程序化交易都有哪些热点争议?
多线程学习
量化程序化交易如何去使用以及执行?
技术分享 | 接口自动化测试如何处理 Header cookie
浅谈一下量化交易与程序化交易
Mind map FreeMind installation problems and simple use
DBCO-PEG-DSPE, Phospholipid-Polyethylene Glycol-Dibenzocyclooctyne, Reaction Without Copper Ion Catalysis
What is a template engine?What are the common template engines?Introduction to common commands of thymeleaf.
暴雨天,看天翼云如何“快准稳”防涝
程序化交易规则对于整个交易系统有什么意义?
Dapp系统开发及智能合约部署技术
【基础版】整数加减乘除计算器
MySQL principle and optimization: Limit the query optimization
异常学习笔记
STSW-LINK00x下载集合,百度云连接
量化投资者是如何获取实时行情数据的呢?
浅析Servlet三大容器的常用方法及其作用域
MySql中什么是索引?常用的索引有哪些种类?索引在什么情况下会失效?
百度开源e-chart初探
对程序化交易系统接口有什么误区?








