4 ms·
Couldn’t you create separate indexes for the 0 and non-0 cases?
by teddyh 3y ago
Couldn’t you create separate indexes for the 0 and non-0 cases?
- recursive 3y agoIf the zeroes are most of the common value, it could be slower to use the index when searching for zeroes. How so? Reading values that aren't included in the index require following a reference back to the table row. If 90% of the rows in your query are zeroes, you'd be better of not using that column in your query planning. A naive filter, possibly even after a table scan, is likely to be faster than using the index.