当前位置:网站首页>What are the conditions of index invalidation?
What are the conditions of index invalidation?
2022-06-13 00:25:00 【Survivors with dreams behind their backs】
List of articles
Column to column contrast
In some table , There are two columns (mobile and phone) They all have separate indexes , The following queries do not go through the index :
select * from test where mobile = phone;
In this case, it is considered that it is better to scan the whole table .
Index column exists NULL value
Mysql Allow in field null when , There is null value , Will it affect the index usage
NOT Conditions
When indexing , An entry will be created for each index , If the query range is equivalent or range query , The index can find the corresponding entry according to the query condition . But when the query condition is not , It is difficult to locate the index , This kind of query conditions are :<>、not、in、not exists.
select * from test where id in (1,3,4,6);
LIKE wildcard
like How to avoid invalidation by using indexes
The conditions include functions
Try not to use functions on index columns , as follows :
select * from test where upper(name) = ‘ZHANGSAN’;
This is not going to be indexed , Because the index may be different at build time and after calculation , Unable to locate index .
But if the query condition is not calculating the index column , Then the accident can be indexed , as follows :
select * from test where name = upper(‘zhangsan’);
Such functions also have :to_char、to_date、to_number、trunc etc. .
The leading column of composite index is distinguished greatly
MySQL Leading column property of Composite Index
Conversion of data types
When the query condition has an implicit transformation , The index will fail . For example, in the database id Deposit is number type , But in the query , But it uses the following form :
select * from test where id = ‘1’;
Connect By、Level
oracle In the database connect by and level Usage of
Predicate operations
We said on it , Cannot perform a function operation on an index column , This also includes the predicate operation of adding and subtracting multipliers , It also invalidates the index . as follows :
select * from test where id/2 = 1;
At this time, you will find out id by 2 The record of , Will invalidate the index . In this case, the index can be used :
select * from test where id = 1*2;
Copyright notice : This paper is about CSDN Blogger 「 The tomato has a fever 」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/bless2015/article/details/84134361
边栏推荐
- 2022施工員-設備方向-通用基礎(施工員)操作證考試題及模擬考試
- [vscode]todo tree a to-do plug-in
- Go custom collation
- Learn to divide subnets in an article
- After so long use, CSDN has finally opened a blog
- PLC peut également faire des jeux - - codesys écrit des jeux de devinettes numériques
- TypeError: wave.ensureState is not a function
- What can PMP bring to you
- USTC of China University of science and technology: Minrui Wang | distribution network voltage stabilization based on transformer Multi-Agent Reinforcement Learning
- The difference between caching and buffering
猜你喜欢
[matlab] matrix transformation and matrix evaluation
Using com0com/com2tcp to realize TCP to serial port (win10)
Using fastjson to solve the problem of returning an empty array from a null value of a field string object
How to gracefully solve the offset problem of Baidu and Gaode maps in leaflet
Successfully installed opencv under delphixe
The PMP examination time in March 2022 is set -- "March 27"
Machining Industry MES system Mold Industry MES system CNCl Medium Industry MES System MES code scanning and reporting MES data collection
Browser cache execution process
PLC也能制作小遊戲----Codesys編寫猜數字小遊戲
USTC of China University of science and technology: Minrui Wang | distribution network voltage stabilization based on transformer Multi-Agent Reinforcement Learning
随机推荐
Explain bio, NiO, AIO in detail
Through MDC, you can easily track your scheduled task log
[LeetCode]3. The longest substring without duplicate characters forty
Installation of IK word breaker
[LeetCode]13. Roman numerals to integers thirty
VHDL programming experiment exercises collection
【Matlab】基础运算
Handling method of wrong heading of VAT special invoice
Maya modeling VI
PMP training organization
3、 Storage system
[matlab] matrix operation
Matlab【路径规划】—— 无人机药品配送路线最优化
进程间通信-共享内存shmat
Go design concurrent web crawler
[GYCTF2020]Ezsqli --BUUCTF
Is the revised PMP worth testing?
June 11, 2022 diary: Mr. Wang's spring, mixed in
PLC也能制作小遊戲----Codesys編寫猜數字小遊戲
[matlab] symbol calculation