mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 04:10:44 -03:30
fix use of distinct on query that UI
When on the screen in the UI that loads the job events, the ui includes a filter to exclude job events where stdout = ''. Because this is a TextField and was not in the allow list, we were applying DISTINCT to the query. This made it very unperformant for large jobs, especially on the query that gets the count and cannot put a LIMIT on the query. Also correctly prefetch the related job_template data on the view to cut down the number of queries we make from around 50 to under 10. We need to analyze other similar views for other prefetch type optimizations we should make.
This commit is contained in:
parent
f1bd1f1dfc
commit
35afb10add
@ -157,7 +157,7 @@ class FieldLookupBackend(BaseFilterBackend):
|
||||
|
||||
# A list of fields that we know can be filtered on without the possiblity
|
||||
# of introducing duplicates
|
||||
NO_DUPLICATES_ALLOW_LIST = (CharField, IntegerField, BooleanField)
|
||||
NO_DUPLICATES_ALLOW_LIST = (CharField, IntegerField, BooleanField, TextField)
|
||||
|
||||
def get_fields_from_lookup(self, model, lookup):
|
||||
|
||||
|
||||
@ -3839,7 +3839,7 @@ class JobJobEventsList(BaseJobEventsList):
|
||||
def get_queryset(self):
|
||||
job = self.get_parent_object()
|
||||
self.check_parent_access(job)
|
||||
return job.get_event_queryset().select_related('host').order_by('start_line')
|
||||
return job.get_event_queryset().prefetch_related('job__job_template', 'host').order_by('start_line')
|
||||
|
||||
|
||||
class JobJobEventsChildrenSummary(APIView):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user