Re: Strange behavior of some volatile function like random(), nextval() - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Strange behavior of some volatile function like random(), nextval()
Date
Msg-id CAB7nPqQYO+4HYmrYGBXE3V9G8fJuUsdZ4U-gMgx91QVPUMmRVw@mail.gmail.com
Whole thread Raw
In response to Strange behavior of some volatile function like random(), nextval()  (Alex Ignatov <a.ignatov@postgrespro.ru>)
Responses Re: Strange behavior of some volatile function like random(), nextval()  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-hackers
On Wed, Jun 29, 2016 at 7:43 PM, Alex Ignatov <a.ignatov@postgrespro.ru> wrote:
> Hello!
>
> Got some strange behavior of random() function:
>
> postgres=# select (select random() ) from generate_series(1,10) as i;
>       random
> -------------------
>  0.831577288918197
> [...]
> (10 rows)

I recall that this is treated as an implicit LATERAL, meaning that
random() is calculated only once.

> postgres=# select (select random()+i*0 ) from generate_series(1,10) as i;
>       ?column?
> --------------------
>    0.97471913928166
> [...]
> (10 rows)

But not that. So those results do not surprise me.
-- 
Michael



pgsql-hackers by date:

Previous
From: Sachin Kotwal
Date:
Subject: pgbench unable to scale beyond 100 concurrent connections
Next
From: Fabien COELHO
Date:
Subject: Re: pgbench unable to scale beyond 100 concurrent connections