wjddn279 commented on code in PR #63640:
URL: https://github.com/apache/airflow/pull/63640#discussion_r2958298016


##########
airflow-core/src/airflow/migrations/versions/0094_3_2_0_replace_deadline_inline_callback_with_fkey.py:
##########
@@ -102,12 +101,45 @@ def migrate_batch(conn, deadline_table, callback_table, 
batch):
                 raise
 
         conn.execute(callback_table.insert(), callback_inserts)
-        conn.execute(
-            deadline_table.update()
-            .where(deadline_table.c.id == sa.bindparam("deadline_id"))
-            .values(callback_id=sa.bindparam("callback_id"), 
missed=sa.bindparam("missed")),
-            deadline_updates,
-        )
+
+        if deadline_updates:
+            # update deadline table by bulk query to improve performance
+            dialect = conn.dialect.name
+
+            if dialect == "postgresql":
+                values_clause = ", ".join(
+                    f"('{row['deadline_id']}'::uuid, 
'{row['callback_id']}'::uuid, {row['missed']})"
+                    for row in deadline_updates
+                )
+                conn.execute(
+                    text(f"""
+                        UPDATE deadline2
+                        SET callback_id = v.callback_id, missed = v.missed
+                        FROM (VALUES {values_clause}) AS v(deadline_id, 
callback_id, missed)
+                        WHERE deadline2.id = v.deadline_id

Review Comment:
   Yes, there was a 
[discussion](https://github.com/apache/airflow/issues/63532#issuecomment-4065575443)
 about this, and it seems to fail depending on the environment. Since there's 
another PR with an alternative fix, I'll close this one.



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