Andrushika commented on code in PR #66854:
URL: https://github.com/apache/airflow/pull/66854#discussion_r3677224222


##########
airflow-core/src/airflow/assets/manager.py:
##########
@@ -359,8 +360,14 @@ def register_asset_change(
             ).unique()
 
             for asset_alias_model in asset_alias_models:
-                asset_alias_model.asset_events.append(asset_event)
-                session.add(asset_alias_model)
+                # Direct INSERT instead of 
asset_alias_model.asset_events.append(...), which
+                # would lazy-load the alias's entire asset_events collection 
just to add one row.
+                session.execute(
+                    insert(asset_alias_asset_event_association_table).values(
+                        alias_id=asset_alias_model.id,
+                        event_id=asset_event.id,
+                    )
+                )

Review Comment:
   I guess these changes are all we need.



##########
airflow-core/src/airflow/assets/manager.py:
##########
@@ -359,8 +360,14 @@ def register_asset_change(
             ).unique()
 
             for asset_alias_model in asset_alias_models:

Review Comment:
   I guess these changes are all we need.



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