pawurb / ruby-pg-extras

Ruby PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more.
MIT License
124 stars 11 forks source link

Feature request: Partial indexes for columns with high % of the same value #17

Closed fatkodima closed 1 year ago

fatkodima commented 2 years ago

This is kind of evolving an idea used in null_indexes. Additionally to suggesting partial indexes when we have a lot of NULLs in the column, we can suggest partial indexes for columns where we have a high % of the same value.

For example, for the table with millions of users an index on role was added (to quickly find admins, for example). But 99% of the users are regular users, several are admins, moderators, etc. So the partial index where role != 'regular' would be beneficial.

pawurb commented 2 years ago

Thanks for an idea! I don't have time to work on it right now but PRs are welcome.