[PR #19304] [MERGED] Fixes #19309: N+1 problem on /interfaces, /ip-addresses and /prefixes requests #15604

Closed
opened 2025-12-30 00:22:57 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19304
Author: @Tishka17
Created: 4/24/2025
Status: Merged
Merged: 5/6/2025
Merged by: @jnovinger

Base: mainHead: fix/nplus1_api


📝 Commits (3)

  • 7d95418 Fixes N+1 problem on /interfaces, /ip-addresses and /prefixes requests
  • 04c731d remove extra .all()
  • 6895b38 more prefetch for IPAddressViewSet

📊 Changes

2 files changed (+16 additions, -2 deletions)

View changed files

📝 netbox/dcim/api/views.py (+1 -0)
📝 netbox/ipam/api/views.py (+15 -2)

📄 Description

Fixes: #19309

In case of requesting /interfaces, /ip-addresses and /prefixes some of the fields are selected separately for each model. We should prefetch them.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/19304 **Author:** [@Tishka17](https://github.com/Tishka17) **Created:** 4/24/2025 **Status:** ✅ Merged **Merged:** 5/6/2025 **Merged by:** [@jnovinger](https://github.com/jnovinger) **Base:** `main` ← **Head:** `fix/nplus1_api` --- ### 📝 Commits (3) - [`7d95418`](https://github.com/netbox-community/netbox/commit/7d95418f9f187a87ce85667acb0d042145cc3ca0) Fixes N+1 problem on /interfaces, /ip-addresses and /prefixes requests - [`04c731d`](https://github.com/netbox-community/netbox/commit/04c731da8f0250dea7ec2255a3a6040b6f65c849) remove extra .all() - [`6895b38`](https://github.com/netbox-community/netbox/commit/6895b389e5a8702f165673c7c47e294db6cd36e6) more prefetch for IPAddressViewSet ### 📊 Changes **2 files changed** (+16 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/api/views.py` (+1 -0) 📝 `netbox/ipam/api/views.py` (+15 -2) </details> ### 📄 Description ### Fixes: #19309 In case of requesting `/interfaces`, `/ip-addresses` and `/prefixes` some of the fields are selected separately for each model. We should prefetch them. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:22:57 +01:00
adam closed this issue 2025-12-30 00:22:57 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15604