delete inside for plpgsql loop on same relation?

From: Rob Nikander <rob(dot)nikander(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: delete inside for plpgsql loop on same relation?
Date: 2019-06-18 18:02:24
Message-ID: C12E9EA5-5B1A-44C7-9A4D-F01F12261A07@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Are there guarantees about how this plpgsql behaves? It’s deleting from a table while it loops over it. So far it seems like the delete is logically after the select, as I hoped, and doesn’t interfere.

for row in select * from some_stuff loop
delete from some_stuff where …
...
end loop;

I’m using a temporary table of “things to process” and looping over it, deleting the ones as I go.

I don’t see anything mentioned here: https://www.postgresql.org/docs/11/plpgsql-control-structures.html#PLPGSQL-RECORDS-ITERATING

Rob

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Curry 2019-06-18 18:08:30 Re: perf tuning for 28 cores and 252GB RAM
Previous Message Tom Lane 2019-06-18 17:47:42 Re: Is array_append O(n)?