Eason09053360 commented on code in PR #73154:
URL: https://github.com/apache/airflow/pull/73154#discussion_r4018631814


##########
airflow-core/src/airflow/dag_processing/bundles/manager.py:
##########
@@ -342,16 +343,30 @@ def _extract_and_sign_template(bundle_name: str) -> 
tuple[str | None, dict]:
                     self.log.debug("Signed URL template for bundle %s", 
bundle_name)
             return new_template_, new_params_
 
-        stored = {b.name: b for b in 
session.scalars(select(DagBundleModel)).all()}
+        # ``teams`` is eager-loaded because ``bundle_to_team`` below touches 
it for every stored
+        # bundle, which would otherwise be one lazy-load round-trip each.
+        stored = {

Review Comment:
   Good catch — switched to `DagBundleModel.get_team_names(stored.keys(), 
session=session)`, the hand-rolled `selectinload` is gone.
   
   Also guarded the clear with `if bundle_to_team.get(name):` — clearing an 
already-empty collection is a no-op, and `bundle_to_team` already tells us 
there is nothing to remove.
   
   Statements touching `team`, with 6 bundles of which 5 are later dropped from 
the config:
   
   |  | `selectinload` | `get_team_names` alone | `get_team_names` + guard |
   | --- | --- | --- | --- |
   | the sync that deactivates | 3 | 8 | 8 |
   | every sync after that | 2 | 7 | 2 |
   
   The counting test now exercises the deactivation path as well; removing the 
guard fails it (`assert 5 == 2`).



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