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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Strange behavior of some volatile function like random(), nextval()
Date: 2016-06-29 15:04:51
Message-ID: 7986.1467212691@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"David G. Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> writes:
> A correlated subquery, on the other hand, has to be called once for every
> row and is evaluated within the context supplied by said row. Each time
> random is called it returns a new value.

> Section 4.2.11 (9.6 docs)
> https://www.postgresql.org/docs/9.6/static/sql-expressions.html#SQL-SYNTAX-SCALAR-SUBQUERIES

> Maybe this could be worded better but the first part talks about a single
> execution while "any one execution" is mentioned in reference to "the
> surrounding query".

> I do think that defining "correlated" and "non-correlated" subqueries
> within this section would be worthwhile.

Hmm ... a quick look around says we don't define or use those terms
anywhere. I agree this could stand to be addressed somewhere, but I'm
not sure if 4.2.11 is the most appropriate place. I don't think the
issue is unique to scalar subqueries.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-06-29 15:14:59 Re: pgbench unable to scale beyond 100 concurrent connections
Previous Message Amit Khandekar 2016-06-29 15:00:21 Re: asynchronous and vectorized execution