sortega commented on code in PR #68568:
URL: https://github.com/apache/airflow/pull/68568#discussion_r3468022365


##########
airflow-core/src/airflow/models/dagrun.py:
##########
@@ -656,6 +686,12 @@ def get_running_dag_runs_to_examine(cls, session: Session) 
-> ScalarResult[DagRu
             .limit(cls.DEFAULT_DAGRUNS_TO_EXAMINE)
         )
 
+        # When dag tags are emitted as metric tags, eagerly load 
dag_model.tags so stats_tags
+        # does not fire a per-DagRun N+1 lazy load in the scheduler loop. Off 
by default, so the
+        # extra load is only paid when the feature is enabled.
+        if airflow_conf.getboolean("metrics", "dag_tags_in_metrics", 
fallback=False):
+            query = 
query.options(joinedload(cls.dag_model).selectinload(DagModel.tags))
+

Review Comment:
   I've changed a bit the strategy:
   - I've added eagerly loading to all hot paths when the feature is enabled
   - We have lazy loading fallback for the other cases



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