ARRAY(subquery) volatility - Mailing list pgsql-hackers

From Michael Fuhr
Subject ARRAY(subquery) volatility
Date
Msg-id 20050816060414.GA6540@winnie.fuhr.org
Whole thread Raw
Responses Re: ARRAY(subquery) volatility  (Joe Conway <mail@joeconway.com>)
Re: ARRAY(subquery) volatility  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Why does the first query below return the same value for each row
while the second query returns random values?  Planner optimization?

test=> SELECT ARRAY(SELECT random()) FROM generate_series(1, 5);     ?column?       
---------------------{0.269273371561092}{0.269273371561092}{0.269273371561092}{0.269273371561092}{0.269273371561092}
(5 rows)

test=> SELECT ARRAY(SELECT random() + x * 0) FROM generate_series(1, 5) AS g(x);     ?column?       
---------------------{0.826863945846848}{0.42534113182935}{0.36419924318986}{0.258920902972538}{0.843205466327819}
(5 rows)

-- 
Michael Fuhr


pgsql-hackers by date:

Previous
From: Thomas Hallgren
Date:
Subject: Re: pl/Ruby, deprecating plPython and Core
Next
From: Tino Wildenhain
Date:
Subject: Re: Testing of MVCC