Re: Avoiding a deadlock

From: Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: pgsql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Avoiding a deadlock
Date: 2013-03-11 15:50:03
Message-ID: CA+6hpakwNG7zXTOh1Q-frWtdovAchqznFwV=kJvOpEL6aVGqTA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> 2) All transactions modify table rows in the same order, e.g. ascending
"id".
> With the big update you can do that by putting an "ORDER BY tg2.id"
into
> the subquery, and with the "little transactions" you'll have to make
sure
> that rows are updated in ascending "id" order.

I agree this would fix the deadlock. It also seems like the least
disruptive way of fixing the problem.

Out of curiosity: any reason the ORDER BY should be in the subquery? It
seems like it ought to be in the UPDATE (if that's allowed).

Thanks,
Paul

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stefan Keller 2013-03-11 15:51:58 How to append an element to a row inside a 2-dim. array?
Previous Message Albe Laurenz 2013-03-11 14:14:12 Re: Avoiding a deadlock