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

2025-07-13 Thread Zhang Mingli
On Jul 11, 2025 at 23:57 +0800, Tom Lane , wrote: > "David G. Johnston" writes: > > On Friday, July 11, 2025, Zhang Mingli 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 specific

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

2025-07-11 Thread DINESH NAIR
the ORDER BY clause on windows function, were the regression test results become deterministic. Thanks in advance Dinesh From: Tom Lane Sent: Friday, July 11, 2025 9:27 PM To: David G. Johnston Cc: Zhang Mingli ; PostgreSQL Hackers Subject: Re: [Question] W

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

2025-07-11 Thread Tom Lane
"David G. Johnston" writes: > On Friday, July 11, 2025, Zhang Mingli 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

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

2025-07-11 Thread David G. Johnston
On Friday, July 11, 2025, Zhang Mingli 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 r

[Question] Window Function Results without ORDER BY Clause

2025-07-11 Thread Zhang Mingli
Hi, I am reaching out to discuss the behavior of window functions in Postgres, specifically regarding the use of the OVER() clause without an ORDER BY  specification. In our recent tests, we observed that the results can be unstable. For example, when executing the following query: SELECT sum(u