Re: Current value of a sequence? - Mailing list pgsql-general

From Tom Lane
Subject Re: Current value of a sequence?
Date
Msg-id 25610.991626589@sss.pgh.pa.us
Whole thread Raw
In response to Current value of a sequence?  (Adam Haberlach <adam@newsnipple.com>)
List pgsql-general
Adam Haberlach <adam@newsnipple.com> writes:
> I'm trying to find the next value that will be assigned by a sequence
> without actually incrementing it (yes, I know it isn't atomic-safe
> and all)

If you aren't very concerned about cross-transaction safety,

    select last_value + increment_by from seq;

is approximately right.

There is a *lot* of discussion about this in the mailing list archives.

            regards, tom lane

pgsql-general by date:

Previous
From: "Tim Mickol"
Date:
Subject: RE: editing postgresql.conf for network access
Next
From: "Tauren Mills"
Date:
Subject: Limiting simultaneous connections