When updating many rows, sending individual UPDATE ... WHERE id = ... statements is slow and chatty.
A practical alternative is a single UPDATE ... FROM joined with a WITH updated_data AS (VALUES ...) CTE.
This pattern:
- sends one statement per batch
- keeps the update logic in SQL
- works great with
psycopg/ prepared parameters - avoids temporary tables for many use cases