Add PostgreSQL indexes for all generic foreign key fields #8917

Closed
opened 2025-12-29 20:42:50 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Dec 5, 2023).

Originally assigned to: @jeremystretch on GitHub.

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.)

Originally created by @jeremystretch on GitHub (Dec 5, 2023). Originally assigned to: @jeremystretch on GitHub. ### 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.)
adam added the status: acceptedtype: housekeeping labels 2025-12-29 20:42:50 +01:00
adam closed this issue 2025-12-29 20:42:50 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8917