Re: key = currval('tab_key_seq') choses SEQSCAN?! - Mailing list pgsql-general

From Eric B.Ridge
Subject Re: key = currval('tab_key_seq') choses SEQSCAN?!
Date
Msg-id A4B80899-67FB-11D8-9391-000A95D98B3E@tcdi.com
Whole thread Raw
In response to Re: key = currval('tab_key_seq') choses SEQSCAN?!  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: key = currval('tab_key_seq') choses SEQSCAN?!  (Joe Conway <mail@joeconway.com>)
List pgsql-general
On Feb 25, 2004, at 8:02 PM, Tom Lane wrote:

> Brandon Craig Rhodes <brandon@oit.gatech.edu> writes:
>> But this same table suddenly becomes unwilling to use an index scan if
>> the target value is the result of the currval() function:
>
> currval() is considered a volatile function, therefore it is unsafe to
> use in an indexscan constraint.

I suppose this is obvious, but it's volatile because *other* backends
can change it while the current transaction is still in progress?

eric

>
> The subselect hack mentioned nearby fools the planner ... at the
> moment.
> I wouldn't guarantee that it will work indefinitely.  A better solution
> is to wrap currval() in a function that you lyingly claim is stable.
>
>             regards, tom lane
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to
> majordomo@postgresql.org)


pgsql-general by date:

Previous
From: "cnliou"
Date:
Subject: Re: invalid memory alloc request size
Next
From: Randall Skelton
Date:
Subject: Simplyfying many equals in a join