Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.postgresql > #109

Re: Deadlock on the same select for update

From "Laurenz Albe" <invite@spam.to.invalid>
Newsgroups comp.databases.postgresql
References <f7c3a742-d9c8-4e38-9708-a9f458a36a59@i14g2000yqe.googlegroups.com> <wZq*U2kwt@news.chiark.greenend.org.uk> <pan.2011.02.23.14.34.04@gmail.com> <zUj*3xvwt@news.chiark.greenend.org.uk>
Subject Re: Deadlock on the same select for update
Date 2011-05-03 09:53 +0200
Organization dienste.wien.at ISP
Message-ID <1304409229.248884@proxy.dienste.wien.at> (permalink)

Show all headers | View raw


Matthew Woodcraft wrote:
> What I don't see a firm guarantee for is that ORDER BY on a SELECT FOR
> UPDATE controls the order in which the locks are taken, as opposed to
> just controlling the order of the result rows.

There's nothing in the documentation, but read Tom Lane's commit message
for a change introduced in 9.0:

http://archives.postgresql.org/pgsql-committers/2009-10/msg00127.php

  Instead, keep the present semantics of applying
  FOR UPDATE after ORDER BY within a single query level; but allow the user to
  specify the other way by writing FOR UPDATE in a sub-select.

So the locks will be taken in the order specified in ORDER BY in a
simple query, but
a) that is not a documented feature and
b) the commit message suggests that that is not written in stone.

So I wouldn't rely on it.

Yours,
Laurenz Albe 

Back to comp.databases.postgresql | Previous | NextNext in thread | Find similar


Thread

Re: Deadlock on the same select for update "Laurenz Albe" <invite@spam.to.invalid> - 2011-05-03 09:53 +0200
  Re: Deadlock on the same select for update Jasen Betts <jasen@xnet.co.nz> - 2011-05-03 08:31 +0000

csiph-web