Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lzQ8o-0003OF-55 for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Jul 2021 20:52:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lzQ8n-0007oG-2k for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Jul 2021 20:52:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lzQ8m-0007o8-Ro for pgsql-hackers@lists.postgresql.org; Fri, 02 Jul 2021 20:52:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lzQ8k-0006fo-SP for pgsql-hackers@lists.postgresql.org; Fri, 02 Jul 2021 20:52:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 162KppVW1155683; Fri, 2 Jul 2021 16:51:51 -0400 From: Tom Lane To: Gavin Flower cc: pgsql-hackers@lists.postgresql.org Subject: Re: Add proper planner support for ORDER BY / DISTINCT aggregates In-reply-to: <17027322-8a85-5803-c86a-4025f6155980@archidevsys.co.nz> References: <5348877.kVHUhDTtjH@aivenronan> <17027322-8a85-5803-c86a-4025f6155980@archidevsys.co.nz> Comments: In-reply-to Gavin Flower message dated "Sat, 03 Jul 2021 08:37:40 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1155681.1625259111.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 02 Jul 2021 16:51:51 -0400 Message-ID: <1155682.1625259111@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Gavin Flower writes: > On 2/07/21 8:39 pm, David Rowley wrote: >> That's a good question. There was an argument in [1] that mentions >> that there might be a group of people who rely on aggregation being >> done in a certain order where they're not specifying an ORDER BY >> clause in the aggregate. If that group of people exists, then it's >> possible they might be upset in the scenario that you describe. > So I think that pg has no obligation to protect the sensibilities of > naive users in this case, especially at the expense of users that want > queries to complete as quickly as possible.  IMHO I agree. We've broken such expectations in the past and I don't have much hesitation about breaking them again. regards, tom lane