Re: [Question] Window Function Results without ORDER BY Clause - Mailing list pgsql-hackers

From Zhang Mingli
Subject Re: [Question] Window Function Results without ORDER BY Clause
Date
Msg-id dca6fd49-5408-499e-b2b5-ad4d08fb6b5c@Spark
Whole thread Raw
In response to Re: [Question] Window Function Results without ORDER BY Clause  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers

On Jul 11, 2025 at 23:57 +0800, Tom Lane <tgl@sss.pgh.pa.us>, wrote:
"David G. Johnston" <david.g.johnston@gmail.com> writes:
On Friday, July 11, 2025, Zhang Mingli <zmlpostgres@gmail.com> wrote:
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.

Well, it's our own regression-test query. I think the actual question
being asked here is "do our regression tests need to pass under random
non-default GUC settings?". I'd say no; it'd be next door to
impossible to guarantee that.
Hi, I didn't mean to imply that our regression tests should pass under random non-default GUC settings.
My concern arose from the development of our distributed databases, such as Greenplum and Apache Cloudberry.
In Postgres, the tuple order remains stable under constant GUC settings(Index Scan, SeqScan and there is no Parallel Seqscan for Window Agg). 
However, in a distributed environment, tuples are spread across segments, and the order in which data is returned to the Master node can be unpredictable. 
This unpredictability can affect the stability of results when calculating window functions.
I just wanted to confirm that both results are correct in the absence of an "ORDER BY" clause. I believe I've received the clarification I needed.
Thank you all!

--
Zhang Mingli
HashData

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Bug on drop extension dependencies ?
Next
From: "David G. Johnston"
Date:
Subject: Re: Bug on drop extension dependencies ?