The GitHub Actions job "Tests AMD/ARM" on airflow.git/dag_n_plus_one has failed.
Run started by GitHub user kaxil (triggered by kaxil).

Head commit for run:
a6b3dd0afaedc4aa889abf11323e333a91c4fec0 / Kaxil Naik <[email protected]>
Fix n+1 query to fetch tags in the dags list page

The `/public/dags` and `/ui/dags` endpoints were triggering n+1 queries
when loading DAG tags - one query to fetch DAGs, then one additional query
per DAG to fetch its tags. For deployments with many DAGs, this could cause
significant performance degradation.

Added `selectinload(DagModel.tags)` to `generate_dag_with_latest_run_query()`
to eagerly load all tags in a single additional query instead of N separate
queries. This reduces the total queries from O(N) to O(1) with respect to
the number of DAGs.

Example impact:
- Before: 1 query for DAGs + 100 queries for tags (100 DAGs) = 101 queries
- After: 1 query for DAGs + 1 query for all tags = 2 queries

Added regression tests that verify query count doesn't scale linearly with
the number of DAGs by comparing counts before and after adding more DAGs.

Fixes #57241

Report URL: https://github.com/apache/airflow/actions/runs/18810517673

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to