> Multiple UNION
operators in the same SELECT
statement are evaluated left to right, unless otherwise indicated by parentheses.
In the case of UNION ALL, is this supposed to mean ...
a.) Individual legs are evaluated left to right, but sets returned from each are not guaranteed to be appended in the same order, nor is the order within each set guaranteed to be preserved.
b.) Individual legs are evaluated left to right, sets returned from each are appended in order, but the order within each set is not guaranteed to be preserved.
c.) Individual legs are evaluated left to right, sets returned from each are appended in order, and the order within each set is guaranteed to be preserved.
d.) The manual is outdated. Since the advent of "Parallel Append" in Postgres 11, left to right evaluation is not guaranteed in all cases.
Obviously, the order *within* each leg is not guaranteed without ORDER BY attached to it, enclosed in parentheses. But that's an orthogonal issue. The question is, what of the returned order is preserved after UNION ALL? And what is *guaranteed*?
I guess the term "evaluated" is ambiguous.
I would love the manual to be clear about this.
Related discussion here:
Regards
Erwin