Re: delete statement returning too many results

2022-12-04 Thread Arlo Louis O'Keeffe
> On 29. Nov 2022, at 18:35, Tom Lane wrote: > > Harmen writes: >> On Mon, Nov 28, 2022 at 12:11:53PM -0500, Tom Lane wrote: >>> So basically it's unsafe to run the sub-select more than once, >>> but the query as written leaves it up to the planner whether >>> to do that. I'd suggest

Re: delete statement returning too many results

2022-11-29 Thread Kirk Wolak
On Mon, Nov 28, 2022 at 9:18 AM Ron wrote: > On 11/28/22 07:29, Arlo Louis O'Keeffe wrote: > > Hello everyone, > > > > I am seeing weird behaviour of a delete statement that is returning more > results than I am expecting. > > > > This is the query: > > > > DELETE FROM queue > > WHERE > >

Re: delete statement returning too many results

2022-11-29 Thread Tom Lane
Harmen writes: > On Mon, Nov 28, 2022 at 12:11:53PM -0500, Tom Lane wrote: >> So basically it's unsafe to run the sub-select more than once, >> but the query as written leaves it up to the planner whether >> to do that. I'd suggest rephrasing as [...] > I'm not the original poster, but I do use

Re: delete statement returning too many results

2022-11-29 Thread Harmen
On Mon, Nov 28, 2022 at 12:11:53PM -0500, Tom Lane wrote: > So basically it's unsafe to run the sub-select more than once, > but the query as written leaves it up to the planner whether > to do that. I'd suggest rephrasing as > > WITH target_rows AS MATERIALIZED ( > SELECT id > FROM

Re: delete statement returning too many results

2022-11-28 Thread Tom Lane
"David G. Johnston" writes: > There is a nice big caution regarding the default read committed isolation > mode, order by, and for update, in the documentation, but I cannot work out > exactly why this example seems to be triggering it. The is talking about a rather different scenario. I

Re: delete statement returning too many results

2022-11-28 Thread David G. Johnston
On Mon, Nov 28, 2022 at 7:18 AM Ron wrote: > On 11/28/22 07:29, Arlo Louis O'Keeffe wrote: > > Hello everyone, > > > > I am seeing weird behaviour of a delete statement that is returning more > results than I am expecting. > > > > This is the query: > > > > DELETE FROM queue > > WHERE > >

Re: delete statement returning too many results

2022-11-28 Thread Ron
On 11/28/22 07:29, Arlo Louis O'Keeffe wrote: Hello everyone, I am seeing weird behaviour of a delete statement that is returning more results than I am expecting. This is the query: DELETE FROM queue WHERE id IN ( SELECT id FROM queue

delete statement returning too many results

2022-11-28 Thread Arlo Louis O'Keeffe
Hello everyone, I am seeing weird behaviour of a delete statement that is returning more results than I am expecting. This is the query: DELETE FROM queue WHERE id IN ( SELECT id FROM queue ORDER BY id LIMIT 1