256,338 rows affected.

you are viewing a single comment's thread
view the rest of the comments
[–] 1 point 1 year ago* (last edited 1 year ago) (1 child)

You can just insert directly to the helper/audit table, and delete using it, no need for the cursor loop. If you need a handle to go through the records one by one, something else has already gone wrong.

  • source
  • parent
  • hideshow 1 child comment
  • [+] 0 points 1 year ago (1 child)
  • [–] 1 point 1 year ago

    At least in PG, that is explicitly not the case, unless I'm misunderstanding:

    Similarly, a PL/pgSQL loop of the form FOR x IN query LOOP .. END LOOP will never use a parallel plan, because the parallel query system is unable to verify that the code in the loop is safe to execute while parallel query is active.

    https://www.postgresql.org/docs/current/when-can-parallel-query-be-used.html

    At any rate, I feel like it's questionable design to have a user making row-by-row decisions on hard deletes.

  • source
  • parent
  • load more comments (-1 replies)