From cfc0d6c1113e70e9591c369920e5f750fab13459 Mon Sep 17 00:00:00 2001 From: Robin Edwards Date: Tue, 31 Mar 2020 21:42:46 +0100 Subject: [PATCH] Prevent sequential scan of task instance table (#8014) The exact dag_id is known so no need to perform a like here which caused a sequential scan. --- airflow/models/dag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/models/dag.py b/airflow/models/dag.py index 6365f15e2d98a4..2c93b150950129 100644 --- a/airflow/models/dag.py +++ b/airflow/models/dag.py @@ -978,7 +978,7 @@ def clear( conditions = [] for dag in self.subdags + [self]: conditions.append( - TI.dag_id.like(dag.dag_id) & + (TI.dag_id == dag.dag_id) & TI.task_id.in_(dag.task_ids) ) tis = tis.filter(or_(*conditions))