当前位置:网站首页>When will the index fail

When will the index fail

2022-06-12 19:50:00 WD Technology

1、 If there is... In the condition or, Even if there is a conditional index, it will not be used ( That's why we try to use as little or Why )
 Insert picture description here
Be careful : Want to use or, And want the index to work , Can only be or Each column in the condition is indexed

2、 For multi-column indexes , Not the first part of use , Index will not be used

3、like The query is based on % start
 Insert picture description here
4、 If the column type is string , Be sure to quote the data in the condition , Otherwise, the index is not used
 Insert picture description here
5、 Column to column contrast
In some table , Two columns a,b Are individually indexed , The following query conditions will not be indexed

select * from test where a = b

6、 There are calculations on the index column

select * from test where upper(name)='SUNYANG';

This is not going to be indexed , Because the query criteria are indexed
When the query condition does not have an index , You can still use the index

select * from test where name=upper('sunyang');
--INDEX RANGE SCAN

7、 Predicate operations

select * from table where id/2 = type_id

8、 Index can be used for range lookup , But behind the scope Condition will invalidate the index

原网站

版权声明
本文为[WD Technology]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202281534381861.html