Skip to content

Commit

Permalink
Optimize SeedDB vlan listing queries
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed May 3, 2022
1 parent 83a7835 commit ac28f0e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions python/nav/web/seeddb/page/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit ac28f0e

Please sign in to comment.