GB6638 opened a new issue, #55071:
URL: https://github.com/apache/airflow/issues/55071

   ### Apache Airflow version
   
   3.0.5
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   We are running 172 DAGs in Airflow. The UI (/dags page) takes around 15 
seconds to load. After profiling network requests, we found that the slowest 
request is:
   
   `GET /airflow/ui/dags/recent_dag_runs?dag_runs_limit=1&limit=50&offset=0`
   
   Looking at the source code, the following line seems to be the main cause of 
slowness:
   
   `dags_with_recent_dag_runs = 
session.execute(dags_with_recent_dag_runs_select_filter)`
   
   The query dags_with_recent_dag_runs_select_filter takes a long time to run 
and seems to be inefficient.
   
   We did not experience this issue before on Airflow 2.9.1. It seems likely 
that changes in the UI in Airflow 3.0.4 caused the query to change, resulting 
in slower response times. Optimizing this query or caching recent DAG runs 
could significantly improve UI performance.
   
   We have already cleaned the metadata database using:
   
   `airflow db clean --clean-before-timestamp '2025-07-01' --skip-archive`
   
   However, even after this, the query still takes a long time when run 
manually.
   
   ### What you think should happen instead?
   
   Query Optimization: The dags_with_recent_dag_runs_select_filter query should 
be rewritten to fetch only the necessary fields and use indexes effectively.
   
   
   ### How to reproduce
   
   1. Access the Airflow UI /dags page.
   
   2. Observe the network request to /airflow/ui/dags/recent_dag_runs.
   
   Notice the slow response time (~10 seconds).
   
   Expected Behavior:
   The /dags UI should load faster even with a large number of DAGs.
   
   ### Operating System
   
   Ubuntu 22.04
   
   ### Versions of Apache Airflow Providers
   
   Airflow 3.0.4
   
   Python version: 3.10,14
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   Virtualenv installation
   
   ### Anything else?
   
   The bottleneck appears to be in the query 
dags_with_recent_dag_runs_select_filter. Optimizing this query or caching 
recent DAG runs could significantly improve UI performance.
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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]

Reply via email to