Open akostadinov opened 2 years ago
I came here wondering about the redundant indices as well. Both MySQL and Postgresql can use the composite indices for those.
is probably redundant because DB engine can use the composite index when querying
It is not "probably", it is for sure in every relational dbms.
These indexes are redundant. Unfortunately, this gem has some problems with correct/non-redundant/useful indexes and PRs involving adding new indexes should be better reviewed. And overall all existing indexes should be reviewed.
In 6_add_missing_indexes_on_taggings.rb [1] I see two seemingly redundant indices created:
Same goes for
And there is one additional reduntant one from 2_add_missing_unique_indices.rb#L12:
Because the composite index starts with
:tagger_id
it seems that a separate index just on:tagger_id
is probably redundant because DB engine can use the composite index when queryingtagger_id
[2]. Same as the other two cases.Did any practical results showed that both indices are needed or is there any other reason to have them both?
P.S. The rollback of this migration does nothing because everything is in
if
condition. So when runningrollback
nothing is rolled back.[1] https://github.com/mbleigh/acts-as-taggable-on/blob/072767bd03b43b18555f58da2c754096e5e82aca/db/migrate/6_add_missing_indexes_on_taggings.rb#L11-L15 [2] https://user3141592.medium.com/single-vs-composite-indexes-in-relational-databases-58d0eb045cbe