Re: [GENERAL] Subselects in select expressions

2011-11-01 Thread Royce Ausburn
On 02/11/2011, at 2:16 PM, Tom Lane wrote: > Royce Ausburn writes: >> [ random() is evaluated only once in ] >> test=# select (select random()) from generate_series(1,10); -- rows are the >> same > >> I understand that it's likely an optimisation thing -- postgres knows >> that the subselect d

Re: [GENERAL] Subselects in select expressions

2011-11-01 Thread Tom Lane
Royce Ausburn writes: > [ random() is evaluated only once in ] > test=# select (select random()) from generate_series(1,10); -- rows are the > same > I understand that it's likely an optimisation thing -- postgres knows > that the subselect doesn't depend on the FROM rows so it evaluates it > on

[GENERAL] Subselects in select expressions

2011-11-01 Thread Royce Ausburn
I'm having trouble understanding why these two queries produce different results: test=# select (select random()) from generate_series(1,10); -- rows are the same ?column? --- 0.770797704812139 0.770797704812139 0.770797704812139 0.770797704812139 0.770797704812139