pickfire commented on code in PR #74401:
URL: https://github.com/apache/airflow/pull/74401#discussion_r4213771516
##########
airflow-core/newsfragments/74401.bugfix.rst:
##########
@@ -0,0 +1 @@
+Fix ``GET /ui/dags`` recent-runs query degradation on large, skewed
``dag_run`` tables: the per-Dag ``UNION ALL`` branches planned as unbounded
backward ``run_after`` index scans for cold Dags; recent runs are now fetched
by one page-scoped ``row_number()`` query.
Review Comment:
Removed in e2e6239b90. Thanks!
##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/dags.py:
##########
@@ -238,16 +242,31 @@ def get_dags(
DagRun.run_after,
DagRun.start_date,
DagRun.state,
+ func.row_number()
+ .over(
+ partition_by=DagRun.dag_id,
+ order_by=(DagRun.run_after.desc(), DagRun.id.desc()),
Review Comment:
Added both in fa42a91e7c:
`test_recent_dag_runs_returns_exactly_n_newest_in_order` (5 runs, limit 3 → the
3 newest, descending) and `test_recent_dag_runs_tie_breaks_on_id_desc` (two
runs tied on run_after → the later-inserted one wins deterministically). Split
into separate commits for easier review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]