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

Add PostgreSQL indexes for all generic foreign key fields #14436

Closed
jeremystretch opened this issue Dec 5, 2023 · 0 comments
Closed

Add PostgreSQL indexes for all generic foreign key fields #14436

jeremystretch opened this issue Dec 5, 2023 · 0 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user
Milestone

Comments

@jeremystretch
Copy link
Member

Proposed Changes

For all GenericForeignKey (GFK) relationships in a model, a PostgreSQL index should be created for its two concrete fields (content type and ID).

Justification

Creating indexes for these fields enables optimized lookup of records by related object. (Django unfortunately does not create these indexes automatically.)

@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user labels Dec 5, 2023
@jeremystretch jeremystretch self-assigned this Dec 5, 2023
@jeremystretch jeremystretch added this to the v3.7 milestone Dec 7, 2023
jeremystretch added a commit that referenced this issue Dec 7, 2023
* Closes #14436: Add PostgreSQL indexes for all GenericForeignKeys

* Add note about GFK indexes to developer docs
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: housekeeping Changes to the application which do not directly impact the end user
Projects
None yet
Development

No branches or pull requests

1 participant