IP address API endpoint triggers excessive database queries, resulting in poor performance #1352

Closed
opened 2025-12-29 16:31:42 +01:00 by adam · 1 comment
Owner

Originally created by @afics on GitHub (Oct 25, 2017).

Issue type

[ ] Feature request
[x] Bug report
[ ] Documentation

Environment

  • Python version: 3.4.2
  • NetBox version: 2.2.1

Description

Certain API calls produce more SQL queries than they have to which results in those calls being "slow".
Example:

200 GET
/api/ipam/ip-addresses/?limit=10000
12106ms overall
2305ms on queries
2374 queries

This is fixed by #1535. While the Pull request is for an older version of Netbox, the newest version is also affected by this problem.
The same API call after applying the patch:

200 GET
/api/ipam/ip-addresses/
3215ms overall
255ms on queries
8 queries
Originally created by @afics on GitHub (Oct 25, 2017). <!-- Before opening a new issue, please search through the existing issues to see if your topic has already been addressed. Note that you may need to remove the "is:open" filter from the search bar to include closed issues. Check the appropriate type for your issue below by placing an x between the brackets. If none of the below apply, please raise your issue for discussion on our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please note that issues which do not fall under any of the below categories will be closed. ---> ### Issue type [ ] Feature request <!-- Requesting the implementation of a new feature --> [x] Bug report <!-- Reporting unexpected or erroneous behavior --> [ ] Documentation <!-- Proposing a modification to the documentation --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) --> ### Environment * Python version: 3.4.2 * NetBox version: 2.2.1 <!-- BUG REPORTS must include: * A list of the steps needed to reproduce the bug * A description of the expected behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description Certain API calls produce more SQL queries than they have to which results in those calls being "slow". Example: ``` 200 GET /api/ipam/ip-addresses/?limit=10000 12106ms overall 2305ms on queries 2374 queries ``` This is fixed by #1535. While the Pull request is for an older version of Netbox, the newest version is also affected by this problem. The same API call after applying the patch: ``` 200 GET /api/ipam/ip-addresses/ 3215ms overall 255ms on queries 8 queries ```
adam added the type: bug label 2025-12-29 16:31:42 +01:00
adam closed this issue 2025-12-29 16:31:42 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 25, 2017):

The IP address serializer embeds the full serializer for the related interface rather than a nested serializer as in other cases. This was done to ensure the parent device was included as well but was probably a mistake. We can implement a slightly extended nested serializer to ensure only the necessary interface details are included. This would remove the need to extend the database query.

@jeremystretch commented on GitHub (Oct 25, 2017): The IP address serializer embeds the full serializer for the related interface rather than a nested serializer as in other cases. This was done to ensure the parent device was included as well but was probably a mistake. We can implement a slightly extended nested serializer to ensure only the necessary interface details are included. This would remove the need to extend the database query.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1352