Skip site navigation (1) Skip section navigation (2)

Re: target list evaluation wrt sequences

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org, elein(at)varlena(dot)com
Subject: Re: target list evaluation wrt sequences
Date: 2004-04-30 16:20:31
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On Fri, Apr 30, 2004 at 01:01:25 -0400,
  Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> > No. You can do effectively this by joining a select nextval to whatever
> > you main select is. Something like:
> > insert into ...
> >        select a.n as a, a.n as b, ....
> >              from (select nextval('n') as n) as a, lalala
> Urgh ... I'd not want to promise that nextval() will always be evaluated
> just once in the above example ... this really seems *much* more fragile
> than assuming left-to-right targetlist evaluation :-(

Thanks for the heads up. I have so far only used that technique to speed up
some queries with respect to using subselects, where the subquery would
always evaluate to the same value anyway.
If I need a single value from a volatile calculation to be used more than
once, I will remember to use a separate query to save the value in a table and
then refer to that value later.

In response to

pgsql-general by date

Next:From: Richard GassDate: 2004-04-30 16:26:48
Subject: Re: TCP only listening on localhost???
Previous:From: Karl O. PincDate: 2004-04-30 15:26:30
Subject: Re: Plpgsql problem passing ROWTYPE to function

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group