defer loading Job.artifacts on host views to improve performance

see: https://github.com/ansible/awx/issues/8006

this data can be *really* large, and we don't actually need it for the summary fields on this API endpoint
This commit is contained in:
Ryan Petrello
2020-08-26 13:20:35 -04:00
parent 48f00587f8
commit 73baf3fcf9
2 changed files with 11 additions and 2 deletions

View File

@@ -48,7 +48,13 @@ class HostManager(models.Manager):
"""When the parent instance of the host query set has a `kind=smart` and a `host_filter`
set. Use the `host_filter` to generate the queryset for the hosts.
"""
qs = super(HostManager, self).get_queryset()
qs = super(HostManager, self).get_queryset().defer(
'last_job__extra_vars',
'last_job_host_summary__job__extra_vars',
'last_job__artifacts',
'last_job_host_summary__job__artifacts',
)
if (hasattr(self, 'instance') and
hasattr(self.instance, 'host_filter') and
hasattr(self.instance, 'kind')):