How to do it…
The most common problem is selecting too much data.
A typical point of confusion comes from data that has a few very common values among a larger group. Requesting data for the very common values costs more because we need to bring back more rows. As we bring back more rows the cost of using the index increases. So it is possible that we won't use the index for the very common values, whereas we would use the index for the less common values. To use an index effectively, make sure you're reducing the number of rows returned.
Another technique for making indexes more usable is partial indexes. Instead of indexing all values in a column, you might choose to index only the set of rows that are frequently accessed; for example, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access