I understand that zeros are not indexed in DB2, therefore, assuming we have a huge table (Sales) with a date column (sold_on), which is usually a date, but sometimes (10% of the time) is null.
Also, suppose this is an outdated application that we cannot change, so these zeros stay there and mean something (say, sales that were returned).
We can quickly execute the following query by specifying an index in the columns sold_on and total
Select * from Sales where Sales.sold_on between date1 and date2 and Sales.total = 9.99
But the index will not make this query faster:
Select * from Sales where Sales.sold_on is null and Sales.total = 9.99
Because indexing is done by value.
Is it possible to index zeros? Maybe changing the type of index? Index column indexing?
source share