Re: Optimisation deficiency: currval('seq')-->seq scan, constant-->index scan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tiago Antão <tra(at)fct(dot)unl(dot)pt>
Cc: Hannu Krosing <hannu(at)tm(dot)ee>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Optimisation deficiency: currval('seq')-->seq scan, constant-->index scan
Date: 2000-08-21 14:50:39
Message-ID: 1823.966869439@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?iso-8859-1?Q?Tiago_Ant=E3o?= <tra(at)fct(dot)unl(dot)pt> writes:
> Isn't the problem more general than just nextval?

Yes it is, and that's why I'm not very excited about the idea of
adding special-case logic for nextval/currval into the optimizer.

It's fairly easy to get around this problem in plpgsql, eg

declare x int;
begin
x := currval('seq');
return f1 from foo where seqfld = x;

so I really am going to resist suggestions that the optimizer should
make invalid assumptions about currval by itself ...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ben Adida 2000-08-21 15:01:49 Re: Bug tracking (was Re: +/- Inf for float8's)
Previous Message Vince Vielhaber 2000-08-21 14:48:17 Re: Bug tracking (was Re: +/- Inf for float8's)