Re: Clarify the ordering guarantees in combining queries (or lack thereof)

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Shay Rojansky <roji(at)roji(dot)org>
Cc: pgsql-docs <pgsql-docs(at)postgresql(dot)org>
Subject: Re: Clarify the ordering guarantees in combining queries (or lack thereof)
Date: 2022-07-14 00:16:08
Message-ID: CAKFQuwZLpXqOs5JhtyLkEhv6Y6TAUK-aJuMOG9v1-zatgrZq5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Wed, Jul 13, 2022 at 5:08 PM Shay Rojansky <roji(at)roji(dot)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.

David J.

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message ideriha.takeshi@fujitsu.com 2022-07-14 02:41:45 RE: No documentation exists about ecpg ORACLE comptaible mode
Previous Message Shay Rojansky 2022-07-14 00:08:17 Clarify the ordering guarantees in combining queries (or lack thereof)