Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Followup from: #2428297: Duplicate index on entity_id column in dedicated field tables
Field tables contain duplicate indexes on the langcode and deleted column. there are no performance-relevant queries that would filter just on that, so we can possibly drop those.
Comment | File | Size | Author |
---|---|---|---|
#9 | duplicate_index_on-2447555-9.patch | 1.94 KB | Cinnead |
#6 | duplicate_index_on-2447555-6.patch | 1.98 KB | Cinnead |
Comments
Comment #1
JeroenTComment #2
BerdirThanks for creating this, I'd like some feedback from yched on this.
Comment #3
yched CreditAttribution: yched commented\Drupal\Core\Entity\Sql\SqlContentEntityStorage::loadFieldItems() does:
This means that the regular "load current revision" operation is ok with the primary key. But a "load a previous revision" operation (which, IIRC, is very frequent with workbench_moderation), wouldn't.
This case would probably be better handled with a dedicated multi-column index on "revision_id, deleted, delta, langcode", rather than currently two separate indexes on 'revision_id' and 'deleted'.
Then, it's possible that at some earlier point the index on 'deleted' was used for purging of deleted values. But currently \Drupal\Core\Entity\Sql\SqlContentEntityStorage::readFieldItemsToPurge() runs
- a first query to determine entity ids (using the index on 'bundle'),
- and then a second query to collect field values on those entity ids (which then uses the primary index)
so it looks like the index on 'deleted' is in fact useless now.
I'm not fully sure about existing queries that might use the 'langcode' index - waving to @plach for that :-)
Comment #4
plachI'm not aware of use cases for queries having conditions on the
langcode
column alone. Given its very low cardinality, thelangcode
index seems pretty useless. Since Views joins dedicated tables based onentity_id
,deleted
andlangcode
columns, a composite index with these three values would seem more useful to me.Makes sense to me too.
Btw, also the
bundle
index does not look very useful.Comment #5
Cinnead CreditAttribution: Cinnead commentedComment #6
Cinnead CreditAttribution: Cinnead at iO commentedRemoved useless indexes.
Comment #7
Cinnead CreditAttribution: Cinnead at iO commentedComment #8
yched CreditAttribution: yched commentedSo,
- It's been established that 'revision_id' and 'deleted' are not needed anymore
- The index on 'bundles' is used by SqlContentEntityStorage::readFieldItemsToPurge() :
so I don't think we can remove it. Back to NW for that.
- According to #3 and #4, we would need new composite indexes. Let's do that in a separate issue - opened #2471635: Missing indexes on dedicated field tables
Comment #9
Cinnead CreditAttribution: Cinnead at iO commentedUpdated the patch to not remove 'bundle'
Comment #10
JeroenTComment #11
yched CreditAttribution: yched commentedThanks, looks good to me :-)
RTBC if green.
Comment #12
JeroenTRTBC when tests are green.
Comment #13
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed f364fc7 and pushed to 8.0.x. Thanks!