Audit for instances where .count() can be replaced with .exists() #199

Closed
opened 2026-04-05 16:22:54 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @jeremystretch on 3/7/2026

NetBox Version

v4.5.4

Python Version

3.12

Area(s) of Concern

  • User Interface
  • REST API
  • GraphQL API
  • Python ORM
  • Other

Details

Came across a few instances where we're evaluating e.g. .count() > 0 rather than using the more efficient .exists() method to check whether one or more objects exist. Let's do a quick audit for others and replace these.

*Originally created by @jeremystretch on 3/7/2026* ### NetBox Version v4.5.4 ### Python Version 3.12 ### Area(s) of Concern - [ ] User Interface - [ ] REST API - [ ] GraphQL API - [x] Python ORM - [ ] Other ### Details Came across a few instances where we're evaluating e.g. `.count() > 0` rather than using the more efficient `.exists()` method to check whether one or more objects exist. Let's do a quick audit for others and replace these.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#199