uranusjr commented on code in PR #30911:
URL: https://github.com/apache/airflow/pull/30911#discussion_r1253955878
##########
airflow/models/dag.py:
##########
@@ -2925,27 +2925,30 @@ def bulk_write_to_db(
session.add(orm_dag)
orm_dags.append(orm_dag)
- # Get the latest dag run for each existing dag as a single query
(avoid n+1 query)
- most_recent_subq = (
- select(DagRun.dag_id,
func.max(DagRun.execution_date).label("max_execution_date"))
- .where(
- DagRun.dag_id.in_(existing_dags),
- or_(DagRun.run_type == DagRunType.BACKFILL_JOB,
DagRun.run_type == DagRunType.SCHEDULED),
+ most_recent_runs: dict[str, DagRun] = {}
+ num_active_runs: dict[str, int] = {}
+ # Save runtime if dag is not scheduleable
Review Comment:
```suggestion
# Skip these queries entirely if no DAGs can be scheduled to save
time.
```
--
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]