"David G. Johnston" <david.g.johnston@gmail.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