Problem/Motivation
The domain_path module adds a domain_id base field to the path_alias entity. All queries in DomainAliasRepository filter by domain_id together with alias or path and langcode.
Core defines four composite indexes on the path_alias tables covering (alias|path, langcode, id, status). The entity system also creates a single-column index on domain_id (path_alias_field__domain_id__target_id). For domain-filtered queries, the database must either intersect two separate indexes or use one and filter the other column from the table — neither is optimal for a high-traffic code path like alias resolution.
By including domain_id in the composite indexes, a single index scan covers (alias|path, langcode, domain_id) together, eliminating the need for index merges or additional lookups.
Proposed resolution
Amend core's four existing indexes to insert domain_id after langcode, using an imperative approach (install/update/uninstall hooks):
| Table | Index name | Amended columns |
|---|---|---|
| path_alias | path_alias__alias_langcode_id_status | alias, langcode, domain_id, id, status |
| path_alias | path_alias__path_langcode_id_status | path, langcode, domain_id, id, status |
| path_alias_revision | path_alias_revision__alias_langcode_id_status | alias, langcode, domain_id, id, status |
| path_alias_revision | path_alias_revision__path_langcode_id_status | path, langcode, domain_id, id, status |
The leftmost prefix (alias|path, langcode) is preserved so core's own queries still benefit from the index.
Implementation in domain_path.install:
domain_path_install()— amends indexes on fresh installdomain_path_update_10007()— amends indexes for existing installsdomain_path_uninstall()— restores core's original indexes before the entity system drops thedomain_idcolumn
Remaining tasks
Review and commit.
Issue fork domain_path-3577052
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
mably commentedComment #4
mably commentedComment #8
mably commented