Indexes can still be used to improve efficiency when the selectivity of the index is low, but the value distribution of the data varies widely.
A, the data distribution is not uniform in the special case, the selective index is also to be created.
The amount of data in table serviceinfo is large, assuming there are 1 million rows, one of which has a field disposalcourseflag, and the value range is the enumeration value: [0,1,2,3,4,5,6,7].
According to the rules established by the previous index, "a field with low selectivity should not be indexed",
This field has only 8 values, the index value is very high repetition rate, the index selectivity is very low, so the index is not built.
However, the distribution of data values on this field is very special, as shown in the following table:
Percentage of the total amount of the range taken
1%
6 98%
7 1%
Moreover, in the common query, the query disposalcourseflag<6 the situation is many and frequent, no doubt, if can establish the index, and is applied,
The query efficiency of this situation will be greatly improved. Therefore, we need to make an index on this field.
Oracle Performance Optimization Operations Seven: Indexing improves query efficiency when data distribution is uneven