On Wed, Jul 13, 2022 at 5:08 PM Shay Rojansky <roji@roji.org> wrote:
Greetings.
I was trying to understand what - if any - are the guarantees with regards to ordering for combining queries (UNION/UNION ALL/...). From this message[1], it seems that UNION ALL does preserve the ordering of the operand queries, whereas UNION does not (presumably neither do INTERSECT, INTERSECT ALL, EXCEPT and EXCEPT ALL).
The documentation[2] makes no mention of this, I'd suggest adding a note clarifying this.
Since the documentation doesn't make a guarantee there is none. If you want ordered output use ORDER BY.