Re: key = currval('tab_key_seq') choses SEQSCAN?!

From: Joe Conway <mail(at)joeconway(dot)com>
To: "Eric B(dot)Ridge" <ebr(at)tcdi(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)postgresql(dot)org, Brandon Craig Rhodes <brandon(at)oit(dot)gatech(dot)edu>
Subject: Re: key = currval('tab_key_seq') choses SEQSCAN?!
Date: 2004-02-26 02:07:32
Message-ID: 403D54E4.2020304@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Eric B.Ridge wrote:
> I suppose this is obvious, but it's volatile because *other* backends
> can change it while the current transaction is still in progress?

No. Other backends don't affect currval, but your own might on a
row-by-row basis. Consider:

regression=# create sequence seq;
CREATE SEQUENCE

regression=# select nextval('seq'), currval('seq'), s from
generate_series(1,4) as t(s);
nextval | currval | s
---------+---------+---
1 | 1 | 1
2 | 2 | 2
3 | 3 | 3
4 | 4 | 4
(4 rows)

Joe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eric B.Ridge 2004-02-26 02:29:33 Re: key = currval('tab_key_seq') choses SEQSCAN?!
Previous Message Randall Skelton 2004-02-26 01:44:40 Simplyfying many equals in a join