Skip to content

Thousands of queries affect Netbox performance #340

@odelarosae

Description

@odelarosae

Plugin Version

0.4.1

NetBox Version

4.4.5

Python Version

3.12.3

Steps to Reproduce

  1. Create a cot
  2. Create a cf > Multiple objects > DCIM Interface
  3. Create 30k instances of cot
  4. Enter to any interface (https://localhost/dcim/interfaces/120/) takes ~25 seconds

Expected Behavior

Perform only one query to see if any cot instance is related to the interface.

Observed Behavior

Netbox perform one query per instance, if you have 30k instances, netbox performs 30k queries.

LOG: duration: 0.257 ms statement: SELECT 1 AS "a" FROM "dcim_interface" WHERE ("dcim_interface"."id" IN (SELECT U0."target_id" AS "target_id" FROM "custom_objects_1_interfaces" U0 WHERE U0."source_id" = 1603) AND "dcim_interface"."id" = 641714) LIMIT 1

if the average duration is 0.25 ms it takes ~7.5 seconds querying, plus latency to the server.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions