You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We do not need all the fields that come back from these queries. I had attempted to cut down on how much data we load in #12045 by using the only directive, but it was later reverted because we determined that because of ways the polymorphic models have secret fields, that this resulted in MORE queries (@AlanCoding helped me find this by hacking the dev environment and using the django debug toolbar. We made the Task Manager only run when we hit an api endpoint in order to get this information.)
I had manually searched through the code to find that we reference ['celery_task_id', 'controller_node', 'created', 'execution_node', 'instance_group', 'job_explanation', 'name', 'pk', 'status'] so the work would consist of finding out which fields are on the models that are NOT in that list, and defer those fields.
kdelee
changed the title
[Tech debt] use "defer" to avoid loading extra (possibly expensive) data in Task Manager
[Performance] use "defer" to avoid loading extra (possibly expensive) data in Task Manager
May 12, 2022
In the task manager, we make a series of queries such as:
https://github.com/ansible/awx/blob/devel/awx/main/scheduler/task_manager.py#L90-L100
awx/awx/main/scheduler/task_manager.py
Line 104 in adb2b0d
awx/awx/main/scheduler/task_manager.py
Line 112 in adb2b0d
We do not need all the fields that come back from these queries. I had attempted to cut down on how much data we load in #12045 by using the
only
directive, but it was later reverted because we determined that because of ways the polymorphic models have secret fields, that this resulted in MORE queries (@AlanCoding helped me find this by hacking the dev environment and using the django debug toolbar. We made the Task Manager only run when we hit an api endpoint in order to get this information.)An alternative approach would be to use
defer
https://docs.djangoproject.com/en/4.0/ref/models/querysets/#defer to specifically exclude certain fields.I had manually searched through the code to find that we reference
['celery_task_id', 'controller_node', 'created', 'execution_node', 'instance_group', 'job_explanation', 'name', 'pk', 'status']
so the work would consist of finding out which fields are on the models that are NOT in that list, and defer those fields.This came up while looking at #11671
The text was updated successfully, but these errors were encountered: