Implement prefetching for GenericForeignKey relationships #10292

Open
opened 2025-12-29 21:29:31 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Sep 25, 2024).

NetBox version

v4.1.1

Feature type

New functionality

Proposed functionality

Update querysets where appropriate to automatically prefetch related objects via GenericForeignKey fields. The ObjectChange model is a good instance where this would be valuable.

Use case

Django 5.0 introduced support for prefetching across GenericForeignKeys. This can reduce the total number of database queries necessary to render a list of objects.

Database changes

N/A

External dependencies

N/A

Originally created by @jeremystretch on GitHub (Sep 25, 2024). ### NetBox version v4.1.1 ### Feature type New functionality ### Proposed functionality Update querysets where appropriate to automatically prefetch related objects via GenericForeignKey fields. The ObjectChange model is a good instance where this would be valuable. ### Use case Django 5.0 introduced support for [prefetching across GenericForeignKeys](https://docs.djangoproject.com/en/5.1/ref/models/querysets/#django.db.models.query.QuerySet.prefetch_related). This can reduce the total number of database queries necessary to render a list of objects. ### Database changes N/A ### External dependencies N/A
adam added the type: featurenetboxstatus: backlogcomplexity: low labels 2025-12-29 21:29:31 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10292