Re: Using random() in update produces same random value for all

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Olleg Samoylov <splarv(at)ya(dot)ru>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Using random() in update produces same random value for all
Date: 2018-01-22 20:01:58
Message-ID: CAMkU=1xi9aRSMfB4Lz2C5yJfekqM4==0JuBTH9LqYcJzXA2-5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jan 22, 2018 at 9:16 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Olleg Samoylov <splarv(at)ya(dot)ru> writes:
> > Looked like random() is "volatile", but in subselect it works like
> "stable".
>
> The point here is that that's an uncorrelated subselect --- ie, it
> contains no outer references --- so it need not be, and is not,
> re-evaluated at every outer row.
>

That seems rather circular. Why shouldn't a volatile be honored as
volatile just because it is in an uncorrelated sub-select?

Cheers,

Jeff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2018-01-22 20:15:55 Re: Using random() in update produces same random value for all
Previous Message Laurenz Albe 2018-01-22 19:52:21 Re: Slow alter sequence with PG10.1