From 28a6af90023a8445a57c27948969ad12f13e6221 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Tue, 3 May 2022 15:48:11 +0200 Subject: [PATCH] Optimize SeedDB vlan listing queries --- python/nav/web/seeddb/page/vlan.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/python/nav/web/seeddb/page/vlan.py b/python/nav/web/seeddb/page/vlan.py index c6bc99435c..c63b00cbf4 100644 --- a/python/nav/web/seeddb/page/vlan.py +++ b/python/nav/web/seeddb/page/vlan.py @@ -80,15 +80,19 @@ class Meta(object): def vlan_list(request): info = VlanInfo() - query = Vlan.objects.extra( - select={ - 'prefixes': ( - "array_to_string(" - "ARRAY(SELECT netaddr FROM prefix " - "WHERE vlanid=vlan.vlanid), ', ')" - ) - } - ).all() + query = ( + Vlan.objects.extra( + select={ + 'prefixes': ( + "array_to_string(" + "ARRAY(SELECT netaddr FROM prefix " + "WHERE vlanid=vlan.vlanid), ', ')" + ) + } + ) + .select_related("net_type", "organization", "usage") + .all() + ) filter_form = VlanFilterForm(request.GET) value_list = ( 'net_type',