From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> |
Cc: | PG-General Mailing List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Ordering of window functions with no order specified? |
Date: | 2017-06-15 05:27:19 |
Message-ID: | CAKFQuwYGnfYUqkMG5=g46YeKTk3Lhpos=Ro545OrhoHA1W572w@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wednesday, June 14, 2017, Ken Tanzer <ken(dot)tanzer(at)gmail(dot)com> wrote:
>
> SELECT a,b,c,row_number()
> OVER (PARTITION BY a) -- Do I need an ORDER BY c,b here?
>
Yes.
> FROM foo
> ORDER BY c,b
>
Also, I'm interested in both what if any behavior is guaranteed, and what
> gets done in practice. (i.e., a SELECT with no order doesn't have
> guarantees, but in practice seems to return the results in the order they
> were added to the table. Is it something similar here?)
>
Row numbers would be assigned in the order they are sent up by the "from
foo" clause.
In practice what gets done depends on the execution plan that is chosen
and nothing is guaranteed unless you specify it in the query so that the
execution plan can enforce it.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Rory Campbell-Lange | 2017-06-15 06:03:46 | Re: Repmgr + pgbouncer - Notification of master promotion to application level ... |
Previous Message | Andreas Kretschmer | 2017-06-15 05:26:57 | Re: Ordering of window functions with no order specified? |