Re: problem with volatile functions in subselects ? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: problem with volatile functions in subselects ?
Date
Msg-id 3576.1154291751@sss.pgh.pa.us
Whole thread Raw
In response to problem with volatile functions in subselects ?  ("Sergey E. Koposov" <math@sai.msu.ru>)
Responses Re: problem with volatile functions in subselects ?  ("Jaime Casanova" <systemguards@gmail.com>)
List pgsql-hackers
"Sergey E. Koposov" <math@sai.msu.ru> writes:
> I see the very strange behaviour with the following set of queries:

> wsdb=# select na,nb, na::double precision as da, nb::double precision  as db from ( select random()::numeric as
na,random()::numericas nb from generate_series(1,2)) as xx;
 

The planner "flattens" this query to a single level of SELECT, so what
you effectively have is

select random()::numeric as na,      random()::numeric as nb,      random()::numeric::double precision as da,
random()::numeric::doubleprecision as db
 
from generate_series(1,2) as xx;

There's been some talk about prohibiting flattening if there are any
volatile functions in the subselect's targetlist, but nothing's been
done about that.  Disabling flattening is a sufficiently big hit to
the planner's optimization ability that it shouldn't be done lightly.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [PATCHES] PATCH to allow concurrent VACUUMs to not lock each
Next
From: Tom Lane
Date:
Subject: Re: Relation locking and relcache load (was Re: Going for "all green" buildfarm results)