-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
N+1 issue on the /api/ipam/ip-addresses/ endpoint #15845
Comments
Thank you for opening a bug report. I was unable to reproduce the reported behavior on NetBox v3.7.6. Please re-confirm the reported behavior on the current stable release and adjust your post above as necessary. Remember to provide detailed steps that someone else can follow using a clean installation of NetBox to reproduce the issue. Remember to include the steps taken to create any initial objects or other data. |
@jeremystretch - forgot to mention that the ips must be assigned. I've updated the post now above + also verified that the issue also affects 3.7.6 As a reference, I created ips like this to reproduce the issue:
|
@jeremystretch - I can fix a PR for this |
@mulmat thanks, I've assigned this to you. A word of caution: be aware that the tables wipe out any prefetches set on the view's queryset, so addressing this will likely need work on the column itself. |
Since this in in the api part I think #15886 should be enough? Or did you also discover this to be an issue in the |
Sorry; I had it in my head that this was for the UI. Disregard my note above! |
Deployment Type
Self-hosted
NetBox Version
v3.7.6
Python Version
3.10
Steps to Reproduce
Call the
/api/ipam/ip-addresses/
endpoint with more than 1 assigned ip address in the database (important that the ip addresses are assigned and you are listing assigned ip addresses, for example by usingassigned_to_interface=true
filter)Expected Behavior
No N+1 issue.
I can submit I PR if wanted (I think the issue is that
IPAddressViewSet
are missingassigned_object_type
in theprefetch_related
)Observed Behavior
N+1 issue with the following query:
SELECT ••• FROM "django_content_type" WHERE "django_content_type"."id" = X LIMIT 21
The text was updated successfully, but these errors were encountered: