pierrejeambrun commented on code in PR #69832:
URL: https://github.com/apache/airflow/pull/69832#discussion_r3637018752


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/grid.py:
##########
@@ -212,24 +225,33 @@ def get_dag_structure(
                 .distinct()
             ),
         )
-        .execution_options(yield_per=5)  # balance between peak memory usage 
and round trips
+        .order_by(SerializedDagModel.id)
     )
-
-    for serdag in session.scalars(serdags_query):
-        filtered_dag = serdag.dag
-        # Apply the same filtering to historical Dag versions
-        if root:
-            filtered_dag = filtered_dag.partial_subset(
-                task_ids=root,
-                include_upstream=include_upstream,
-                include_downstream=include_downstream,
-                depth=depth,
-            )
-        # Merge immediately instead of collecting all Dags in memory
-        nodes = [task_group_to_dict_grid(x) for x in 
task_group_sort(filtered_dag.task_group)]
-        _merge_node_dicts(merged_nodes, nodes)
-
-        session.expunge(serdag)  # to allow garbage collection
+    serdag_ids = list(session.scalars(serdag_id_query))
+    # Release the request session's transaction/connection before the batched 
work.
+    session.commit()

Review Comment:
   `session.close()` reads better here and achieve the same



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