Fixes #19309: N+1 problem on /interfaces, /ip-addresses and /prefixes requests (#19304)

* Fixes N+1 problem on /interfaces, /ip-addresses and /prefixes requests

* remove extra .all()

* more prefetch for IPAddressViewSet
This commit is contained in:
Andrey Tikhonov
2025-05-06 18:47:44 +02:00
committed by GitHub
parent 94618a9dfb
commit 145ee11a3f
2 changed files with 16 additions and 2 deletions

View File

@@ -461,6 +461,7 @@ class InterfaceViewSet(PathEndpointMixin, NetBoxModelViewSet):
Interface.objects.select_related("device", "cable"),
],
),
'virtual_circuit_termination',
'l2vpn_terminations', # Referenced by InterfaceSerializer.l2vpn_termination
'ip_addresses', # Referenced by Interface.count_ipaddresses()
'fhrp_group_assignments', # Referenced by Interface.count_fhrp_groups()