gregnavis / active_record_doctor

Identify database issues before they hit production.
MIT License
1.76k stars 55 forks source link

Suggestion regarding indexes on boolean fields #109

Open fatkodima opened 2 years ago

fatkodima commented 2 years ago

Indexes on booleans are not as useful as people tend to think. On my laptop using postgres (default configuration) index was only used when <= 20% of rows satisfied the target value.

Most of the time, people add indexes for boolean columns like admin, deleted, banned, which have a distribution of 1% vs 99%, so the partial index would help.

So, I propose to suggest removing indexes on boolean fields or make them partial.

gregnavis commented 2 years ago

Great idea. Let's wait with development until I clear up the PR backlog.