N+1 problem in dcim/ipam API calls #11081

Closed
opened 2025-12-29 21:40:00 +01:00 by adam · 1 comment
Owner

Originally created by @Tishka17 on GitHub (Apr 24, 2025).

Originally assigned to: @Tishka17 on GitHub.

Deployment Type

Self-hosted

NetBox Version

v4.2.8

Python Version

3.10

Steps to Reproduce

  1. Enable SQL logging
  2. Do API requests:
  • api/ipam/ip-addresses/
  • api/ipam/prefixes
  • api/dcim/interfaces

Expected Behavior

All required data is loaded by batch SQL requests

Observed Behavior

In the output you will see repeated SQL calls for each object in the response set:

  • circuits_virtualcircuittermination for interfaces
  • dcim_interface folowing by dcim_device for ip-address
  • dcim_site for prefixes
Originally created by @Tishka17 on GitHub (Apr 24, 2025). Originally assigned to: @Tishka17 on GitHub. ### Deployment Type Self-hosted ### NetBox Version v4.2.8 ### Python Version 3.10 ### Steps to Reproduce 1. Enable SQL logging 2. Do API requests: * api/ipam/ip-addresses/ * api/ipam/prefixes * api/dcim/interfaces ### Expected Behavior All required data is loaded by batch SQL requests ### Observed Behavior In the output you will see repeated SQL calls for each object in the response set: * `circuits_virtualcircuittermination` for interfaces * `dcim_interface` folowing by `dcim_device` for ip-address * `dcim_site` for prefixes
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:40:00 +01:00
adam closed this issue 2025-12-29 21:40:00 +01:00
Author
Owner

@Tishka17 commented on GitHub (Apr 24, 2025):

I understand that PR was not recommended to create, but I needed these changes to validate my hypotesis.

@Tishka17 commented on GitHub (Apr 24, 2025): I understand that PR was not recommended to create, but I needed these changes to validate my hypotesis.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11081