Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wmVDL-000ow4-1F for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Jul 2026 11:34:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wmVDK-00Bl4V-33 for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Jul 2026 11:34:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wmVDK-00Bl4N-2F for pgsql-bugs@lists.postgresql.org; Wed, 22 Jul 2026 11:34:14 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wmVDH-00000000b1D-4Bbg for pgsql-bugs@lists.postgresql.org; Wed, 22 Jul 2026 11:34:14 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 66MBY1gW1364085; Wed, 22 Jul 2026 07:34:01 -0400 From: Tom Lane To: Thom Brown cc: 2320415112@qq.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19567: Redundant outer DISTINCT causes a second full aggregation above UNION In-reply-to: References: <19567-a99eb73efbfb32fe@postgresql.org> Comments: In-reply-to Thom Brown message dated "Wed, 22 Jul 2026 11:38:43 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1364083.1784720041.1@sss.pgh.pa.us> Date: Wed, 22 Jul 2026 07:34:01 -0400 Message-ID: <1364084.1784720041@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thom Brown writes: > This doesn't look like a bug, but rather an enhancement request. Yeah, not one of these are bugs. Some of them might be missed optimization opportunities. But you'd need to show that the extra planning cost of detecting such cases is worthwhile, ie there's a reasonably large fraction of real-world queries that would benefit materially. regards, tom lane