From 2906eae348075f930e5e43418c8b7f7405d9dba2 Mon Sep 17 00:00:00 2001 From: Michael Petro Date: Mon, 21 Nov 2022 11:42:30 -0500 Subject: [PATCH 1/2] dagrun, next_dagruns_to_examine, add MySQL index hint --- airflow/models/dagrun.py | 1 + 1 file changed, 1 insertion(+) diff --git a/airflow/models/dagrun.py b/airflow/models/dagrun.py index cd4a27d08977d..b4a4b2fbd517f 100644 --- a/airflow/models/dagrun.py +++ b/airflow/models/dagrun.py @@ -292,6 +292,7 @@ def next_dagruns_to_examine( # TODO: Bake this query, it is run _A lot_ query = ( session.query(cls) + .with_hint(cls, 'USE INDEX (idx_dag_run_running_dags)', dialect_name='mysql') .filter(cls.state == state, cls.run_type != DagRunType.BACKFILL_JOB) .join(DagModel, DagModel.dag_id == cls.dag_id) .filter(DagModel.is_paused == false(), DagModel.is_active == true()) From c4c71123d1e123850fba7421e7767a8acdb4268f Mon Sep 17 00:00:00 2001 From: Michael Petro Date: Mon, 21 Nov 2022 14:22:34 -0500 Subject: [PATCH 2/2] resolve static check errors --- airflow/models/dagrun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airflow/models/dagrun.py b/airflow/models/dagrun.py index b4a4b2fbd517f..5a4df571b381d 100644 --- a/airflow/models/dagrun.py +++ b/airflow/models/dagrun.py @@ -292,7 +292,7 @@ def next_dagruns_to_examine( # TODO: Bake this query, it is run _A lot_ query = ( session.query(cls) - .with_hint(cls, 'USE INDEX (idx_dag_run_running_dags)', dialect_name='mysql') + .with_hint(cls, "USE INDEX (idx_dag_run_running_dags)", dialect_name="mysql") .filter(cls.state == state, cls.run_type != DagRunType.BACKFILL_JOB) .join(DagModel, DagModel.dag_id == cls.dag_id) .filter(DagModel.is_paused == false(), DagModel.is_active == true())