mirror of
https://github.com/ansible/awx.git
synced 2026-05-15 21:37:42 -02:30
optimize a slow query in inventory script generation
if we don't preload this column, Django needs it, and so it generates one query per-host (!!!) to get it. For large (10k+ host) inventories, this is incredibly slow. see: https://github.com/ansible/awx/issues/3214
This commit is contained in:
@@ -239,7 +239,7 @@ class Inventory(CommonModelNameNotUnique, ResourceMixin, RelatedJobsMixin):
|
||||
hosts_kw = dict()
|
||||
if not show_all:
|
||||
hosts_kw['enabled'] = True
|
||||
fetch_fields = ['name', 'id', 'variables']
|
||||
fetch_fields = ['name', 'id', 'variables', 'inventory_id']
|
||||
if towervars:
|
||||
fetch_fields.append('enabled')
|
||||
hosts = self.hosts.filter(**hosts_kw).order_by('name').only(*fetch_fields)
|
||||
|
||||
Reference in New Issue
Block a user