pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Markus Bertheau <twanger@bluetwanger.de>
Cc: Jean-Luc Lachance <jllachan@sympatico.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: SELECT MAX(c) FROM (SELECT ... FOR UPDATE) AS foo
Date: Tue, 17 Aug 2004 12:31:50 -0500
Message-ID: <20040817173150.GA22036@wolff.to> (raw)
In-Reply-To: <1092754281.2627.28.camel@dicaprio.akademie1.de>
References: <1092740863.2627.17.camel@dicaprio.akademie1.de>
	<41221580.7070907@sympatico.ca>
	<1092754281.2627.28.camel@dicaprio.akademie1.de>

On Tue, Aug 17, 2004 at 16:51:21 +0200,
  Markus Bertheau <twanger@bluetwanger.de> wrote:
> ?? ??????, 17.08.2004, ?? 16:26, Jean-Luc Lachance ??????????:
> > This query does not make sense to me.
> > Why would you create an updatable subquery just to get the highest value?
> 
> To make sure that the highest value will be the highest value (or then
> second-highest) after I commit the transaction. See my other answer.

If you just need ordering that isn't too sensitive to overlapping transactions,
then using a sequence (using a serial type is a convenient way to do this)
is probably your best bet. You need to make sure the value won't roll over.
But at worst a bigserial should be needed to do this.
There will potentially be gaps in the numbers allocated accross the table.
There will be gaps in the numbers allocated for any value of name. However,
if all you need is ordering that shouldn't matter.



view thread (8+ messages)

Message-ID: <20040817173150.GA22036@wolff.to>
Permalink:  ../20040817173150.GA22036@wolff.to/
Also on:    postgresql.org/message-id/20040817173150.GA22036@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, twanger@bluetwanger.de, jllachan@sympatico.ca
  Subject: Re: SELECT MAX(c) FROM (SELECT ... FOR UPDATE) AS foo
  In-Reply-To: <20040817173150.GA22036@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox