Re: [Question] Window Function Results without ORDER BY Clause

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Zhang Mingli <zmlpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [Question] Window Function Results without ORDER BY Clause
Date: 2025-07-11 13:27:45
Message-ID: CAKFQuwZE-6ezOJprZeMgDFLUU79kD_x+4_Qh90_WT=ekJcrEaw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Friday, July 11, 2025, Zhang Mingli <zmlpostgres(at)gmail(dot)com> wrote:

>
> Referring to the SQL 2011 standard, it states that if ORDER BY is
> omitted, the order of rows in the partition is undefined.
> While using a window function without ORDER BY is valid, the resulting
> output seems unpredictable.
>
> So, are both result sets technically correct given the absence of an ORDER
> BY clause?
>

The system is behaving within the requirements of the specification. The
query itself is bugged code that the query author should fix.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2025-07-11 14:09:24 Re: track needed attributes in plan nodes for executor use
Previous Message Andrey Borodin 2025-07-11 12:38:36 Re: amcheck: support for GiST