This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 8217e8fccca67d2915375f625d55e5652603b66c
Author: Charlie Jones <[email protected]>
AuthorDate: Mon Oct 13 11:32:04 2025 -0500

    Optimize grid structure query with DISTINCT for dag_version_id lookup 
(#56565)
    
    The grid structure endpoint was scanning hundreds or thousands of
    TaskInstance rows when only a few unique dag_version_id values were
    needed. With mapped tasks, this caused 30+ second load times.
    
    Adding .distinct() reduces the subquery results from potentially
    1000s of rows to just 1-5 unique dag_version_ids, dramatically
    improving performance for DAGs with mapped tasks.
    
    (cherry picked from commit e75657a047fc5aa24aed3620b9bf3119d1b20e43)
---
 airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py 
b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py
index 0c475c985dd..0379bd957ca 100644
--- a/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py
+++ b/airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py
@@ -171,6 +171,7 @@ def get_dag_structure(
                 .where(
                     DagRun.id.in_(run_ids),
                 )
+                .distinct()
             ),
         )
     )

Reply via email to