Re: how to avoid deadlock on masive update with multiples delete

From: Claudio Freire <klaussfreire(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-performance(at)postgresql(dot)org, Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Anibal David Acosta <aa(at)devshock(dot)com>
Subject: Re: how to avoid deadlock on masive update with multiples delete
Date: 2012-10-05 15:58:52
Message-ID: CAGTBQpaN6zwr=-EQYYC4cR4iK0PaKTTckA3ChBzppu90rYwJuQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Oct 5, 2012 at 12:46 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> FOR c IN SELECT ctid FROM table WHERE ... ORDER BY ... LOOP
> DELETE FROM table WHERE ctid = c;
> END LOOP;

Maybe, in that sense, it would be better to optimize client-server
protocol for batch operations.

PREPARE blah(c) AS DELETE FROM table WHERE ctid = $1;

EXECUTE blah(c1), blah(c2), blah(c3), ...
^ 1 transaction, 1 roundtrip, multiple queries

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2012-10-05 16:21:01 Re: how to avoid deadlock on masive update with multiples delete
Previous Message Merlin Moncure 2012-10-05 15:55:39 Re: how to avoid deadlock on masive update with multiples delete