Re: how to avoid deadlock on masive update with multiples delete - Mailing list pgsql-performance

From Tom Lane
Subject Re: how to avoid deadlock on masive update with multiples delete
Date
Msg-id 10891.1349454061@sss.pgh.pa.us
Whole thread Raw
In response to Re: how to avoid deadlock on masive update with multiples delete  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-performance
Merlin Moncure <mmoncure@gmail.com> writes:
> Can't it be forced like this (assuming it is in fact a vanilla order
> by problem)?

> EXPLAIN DELETE FROM test USING (SELECT g FROM test ORDER BY
> ctid FOR UPDATE) x where x.g = test.g;

> (emphasis on 'for update')

Hm ... yeah, that might work, once you redefine the problem as "get the
row locks in a consistent order" rather than "do the updates in a
consistent order".  But I'd be inclined to phrase it as

EXPLAIN DELETE FROM test USING (SELECT ctid FROM test ORDER BY
g FOR UPDATE) x where x.ctid = test.ctid;

I'm not sure that "ORDER BY ctid" is really very meaningful here; think
about FOR UPDATE switching its attention to updated versions of rows.

            regards, tom lane


pgsql-performance by date:

Previous
From: Claudio Freire
Date:
Subject: Re: how to avoid deadlock on masive update with multiples delete
Next
From: Andres Freund
Date:
Subject: Re: how to avoid deadlock on masive update with multiples delete