Re: Strange behavior of some volatile function like random(), nextval()

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Strange behavior of some volatile function like random(), nextval()
Date: 2016-06-29 11:34:59
Message-ID: CAB7nPqQYO+4HYmrYGBXE3V9G8fJuUsdZ4U-gMgx91QVPUMmRVw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 29, 2016 at 7:43 PM, Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2016-06-29 11:37:46 Re: pgbench unable to scale beyond 100 concurrent connections
Previous Message Sachin Kotwal 2016-06-29 10:47:44 pgbench unable to scale beyond 100 concurrent connections