It depends on a few things.
First, the distribution of values. If you have only five different values, but one of them is 99.9999% of the rows in the table, then obviously you do not want the optimizer to use the index for this value, but you can use it for others. In some cases, like this, it's worth using a function-based index to make sure that you index only the values ββof interest, and not those that just take up space.
Secondly, are there any queries that can be answered using this index without access to the table?
Please note that this is not only the percentage of rows that will be accessed, but the number of table blocks that will need to be accessed. For example, if on average you have a table of 1000 blocks and 30 rows per block, and one column has 30 different values ββ(each of which is present in 1000 rows), then the number of blocks you need to visit to read each row for one value varies from 1000/30 = 34 (you should use the index) and 1000 (you should not use the index) depending on how the rows are distributed. this is expressed by the index clustering coefficient - if the value is close to the number of rows in the table, then the index is less likely to be used, and if it is close to the number of blocks, then it is most likely to be used.
You can also look at index compression to see if this saves your space.
Be careful with raster image indices - they are not system-friendly in which they can be changed by several sessions at the same time (for example, two people insert rows into an indexed table at the same time).
A more efficient strategy, if you want to increase the efficiency of queries with predicates for these five values, is to use partitioning, partly because of the clipping of the section in the query, and also because of the improved statistics available to the optimizer, when it knows that only one partition and can use partition level statistics instead of global statistics.
David aldridge
source share