optimize a slow query in inventory script generation

see: https://github.com/ansible/awx/issues/4461
This commit is contained in:
Ryan Petrello 2019-08-14 15:03:53 -04:00
parent 7374732d9b
commit 98e7ae5f9f
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777

View File

@ -309,7 +309,7 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin, RelatedJobsMixin):
# Now use in-memory maps to build up group info.
all_group_names = []
for group in self.groups.only('name', 'id', 'variables'):
for group in self.groups.only('name', 'id', 'variables', 'inventory_id'):
group_info = dict()
if group.id in group_hosts_map:
group_info['hosts'] = group_hosts_map[group.id]