[PR #5385] [MERGED] Closes #4865: Replace all Count() annotations with subqueries #13014

Closed
opened 2025-12-29 22:24:54 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/5385
Author: @jeremystretch
Created: 11/25/2020
Status: Merged
Merged: 11/25/2020
Merged by: @jeremystretch

Base: developHead: 4865-subquery-counts


📝 Commits (8)

  • 0b068ef Convert circuits to use subqueries
  • 5bc0e1a Convert dcim to use subqueries
  • d991e8d Convert extras to use subqueries
  • ea5696e Convert ipam to use subqueries
  • c138712 Convert secrets to use subqueries
  • 52069c8 Convert virtualization to use subqueries
  • a43f2c8 Update global search view to use subqueries where appropriate
  • aead9ac Remove extraneous order_by() calls

📊 Changes

13 files changed (+134 additions, -103 deletions)

View changed files

📝 netbox/circuits/api/views.py (+6 -5)
📝 netbox/circuits/views.py (+16 -6)
📝 netbox/dcim/api/views.py (+14 -14)
📝 netbox/dcim/views.py (+23 -19)
📝 netbox/extras/api/views.py (+4 -5)
📝 netbox/extras/views.py (+9 -9)
📝 netbox/ipam/api/views.py (+9 -10)
📝 netbox/ipam/views.py (+12 -9)
📝 netbox/netbox/views.py (+13 -9)
📝 netbox/secrets/api/views.py (+3 -3)
📝 netbox/secrets/views.py (+7 -3)
📝 netbox/virtualization/api/views.py (+5 -6)
📝 netbox/virtualization/views.py (+13 -5)

📄 Description

Closes: #4865

  • Replace all Count() annotations with subqueries (using get_subquery())
  • Remove all redundant calls to .order_by() on annotated querysets

🔄 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/5385 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 11/25/2020 **Status:** ✅ Merged **Merged:** 11/25/2020 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `4865-subquery-counts` --- ### 📝 Commits (8) - [`0b068ef`](https://github.com/netbox-community/netbox/commit/0b068efe1745fc66f1b76671f24c40b7aac488a0) Convert circuits to use subqueries - [`5bc0e1a`](https://github.com/netbox-community/netbox/commit/5bc0e1abeac8e7b5aa6a70f3c7cf3f1d15b7513a) Convert dcim to use subqueries - [`d991e8d`](https://github.com/netbox-community/netbox/commit/d991e8d0079f581ce1afe25e1ab1ab7b9c96165f) Convert extras to use subqueries - [`ea5696e`](https://github.com/netbox-community/netbox/commit/ea5696e700157ac557c59446e38e0f420a93b7ef) Convert ipam to use subqueries - [`c138712`](https://github.com/netbox-community/netbox/commit/c138712dd3b2eec9585405f2f6bac799c9f90b91) Convert secrets to use subqueries - [`52069c8`](https://github.com/netbox-community/netbox/commit/52069c8a43bbddb89f8ae678a58e64d30351e802) Convert virtualization to use subqueries - [`a43f2c8`](https://github.com/netbox-community/netbox/commit/a43f2c89c1fdd5c51f591506fd6f15823103270e) Update global search view to use subqueries where appropriate - [`aead9ac`](https://github.com/netbox-community/netbox/commit/aead9ac516c9fa8520bf2964f070efbe6845f243) Remove extraneous order_by() calls ### 📊 Changes **13 files changed** (+134 additions, -103 deletions) <details> <summary>View changed files</summary> 📝 `netbox/circuits/api/views.py` (+6 -5) 📝 `netbox/circuits/views.py` (+16 -6) 📝 `netbox/dcim/api/views.py` (+14 -14) 📝 `netbox/dcim/views.py` (+23 -19) 📝 `netbox/extras/api/views.py` (+4 -5) 📝 `netbox/extras/views.py` (+9 -9) 📝 `netbox/ipam/api/views.py` (+9 -10) 📝 `netbox/ipam/views.py` (+12 -9) 📝 `netbox/netbox/views.py` (+13 -9) 📝 `netbox/secrets/api/views.py` (+3 -3) 📝 `netbox/secrets/views.py` (+7 -3) 📝 `netbox/virtualization/api/views.py` (+5 -6) 📝 `netbox/virtualization/views.py` (+13 -5) </details> ### 📄 Description ### Closes: #4865 - Replace all `Count()` annotations with subqueries (using `get_subquery()`) - Remove all redundant calls to `.order_by()` on annotated querysets --- <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-29 22:24:54 +01:00
adam closed this issue 2025-12-29 22:24:54 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#13014