You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 querying tagger_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 running rollback nothing is rolled back.
I came here wondering about the redundant indices as well. Both MySQL and Postgresql can use the composite indices for those.
akostadinov
changed the title
migration 6_add_missing_indexes_on_taggings redundant inxed?
migration 6_add_missing_indexes_on_taggings redundant index?
Nov 23, 2021
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]
acts-as-taggable-on/db/migrate/6_add_missing_indexes_on_taggings.rb
Lines 11 to 15 in 072767b
[2] https://user3141592.medium.com/single-vs-composite-indexes-in-relational-databases-58d0eb045cbe
The text was updated successfully, but these errors were encountered: