Skip to content

Skip implicit foreign key index covered by a unique constraint - #7476

Closed
lazerg wants to merge 1 commit into
doctrine:4.4.xfrom
lazerg:skip-implicit-fk-index-covered-by-unique-constraint
Closed

Skip implicit foreign key index covered by a unique constraint#7476
lazerg wants to merge 1 commit into
doctrine:4.4.xfrom
lazerg:skip-implicit-fk-index-covered-by-unique-constraint

Conversation

@lazerg

@lazerg lazerg commented Jul 25, 2026

Copy link
Copy Markdown
Q A
Type bug
Fixed issues Fixes #7459

Summary

When a foreign key's referencing columns are already covered by a unique constraint, DBAL still added an implicit backing index for the foreign key. On MySQL and MariaDB the unique constraint's own index already backs the foreign key, so that extra index is redundant and just duplicates it. DBAL already skips the implicit index when a regular index spans the same columns. This applies the same check to unique constraints.

@morozov

morozov commented Jul 26, 2026

Copy link
Copy Markdown
Member

@lazerg unless you really need this change in, I'd prefer to erradicate this issue and remove this functionality entirely (#7477).

@lazerg

lazerg commented Jul 26, 2026

Copy link
Copy Markdown
Author

No, nothing critical riding on this one. If #7477 removes the implicit index entirely and covers this case, I'm happy to close in favor of that. Thanks for taking a look.

@morozov morozov closed this Jul 26, 2026
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

Successfully merging this pull request may close these issues.

Redundant foreign-key backing index when a unique constraint covers the same columns

2 participants