Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unindexed foreign keys many-to-many table #22943

Open
thedevdavid opened this issue Apr 20, 2024 · 1 comment
Open

Unindexed foreign keys many-to-many table #22943

thedevdavid opened this issue Apr 20, 2024 · 1 comment

Comments

@thedevdavid
Copy link
Contributor

Performance advisor reports unindexed foreign keys for a junction table. Is this necessary if the junction table has a composite primary key as a unique index?

image image image
@thedevdavid thedevdavid added the bug Something isn't working label Apr 20, 2024
@encima
Copy link
Contributor

encima commented Apr 22, 2024

This depends on query usage you have, the index you get "for free" is a composite on tracks_id and playlist_id but you may have queries that are just querying the tracks_id in the table or, possibly, querying both but in a different order such that it is not used.

The advice is not wrong but I do see that this may also result in over-indexing. Not sure this is a bug but we could move it to discussions to see what others think?

@encima encima removed the bug Something isn't working label Apr 22, 2024
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

No branches or pull requests

2 participants