Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several redundant indexes are possibly created by the default migration files generated #1083

Open
virajvchavan opened this issue May 22, 2022 · 1 comment

Comments

@virajvchavan
Copy link

virajvchavan commented May 22, 2022

I was using active-record-doctor to check for possible issues with the DB schema and noticed it showed the following notices related to acts-as-taggable-on

remove index_taggings_on_tag_id - can be replaced by taggings_idx
remove index_taggings_on_taggable_id - can be replaced by taggings_idy or taggings_taggable_context_idx
remove index_taggings_on_taggable_type - can be replaced by index_taggings_on_taggable_type_and_taggable_id
remove index_taggings_on_tagger_id - can be replaced by index_taggings_on_tagger_id_and_tagger_type

These indices were added by the migration file generated by the command rake acts_as_taggable_on_engine:install:migrations.

In general, a multi-column index on column_1, column_2, ..., column_n can replace indexes on:

- column_1
- column_1, column_2
- ...
- column_1, column_2, ..., column_(n - 1)

Or is there a practical reason to keep these indices?

@fatkodima
Copy link
Contributor

These are all valid suggestions from active_record_doctor. I think, these all extra indexes appeared as an oversight over time.
It is needed to do an audit of indexes for this gem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants