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

From Tom Lane
Subject Re: key = currval('tab_key_seq') choses SEQSCAN?!
Date
Msg-id 8016.1077757377@sss.pgh.pa.us
Whole thread Raw
In response to key = currval('tab_key_seq') choses SEQSCAN?!  (Brandon Craig Rhodes <brandon@oit.gatech.edu>)
Responses Re: key = currval('tab_key_seq') choses SEQSCAN?!
List pgsql-general
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.

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

pgsql-general by date:

Previous
From: Michael Chaney
Date:
Subject: Re: Moving from MySQL to PGSQL....some questions
Next
From: "cnliou"
Date:
Subject: Re: invalid memory alloc request size