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.94.2) (envelope-from ) id 1sgS4F-002M17-7K for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Aug 2024 16:50:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sgS4D-001eEB-B2 for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Aug 2024 16:50:45 +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.94.2) (envelope-from ) id 1sgS4D-001eE3-07 for pgsql-hackers@lists.postgresql.org; Tue, 20 Aug 2024 16:50:45 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sgS49-000dtD-OH for pgsql-hackers@postgresql.org; Tue, 20 Aug 2024 16:50:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=momjian.us; s=2024011501; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description; bh=9KJuPVyV1wp6mqJ+/KW+1iNwCmmOLdg+ZDDjSlOI+7o=; b=fpd4s Qf9jDmzT1+btLKrVmmxW+1lfuaMLGrO5NtustdDhZplRDzee9H2qkROjvxJzUm6YLhGAHPvlZ4ffK 4jYcPA0mGpdoAVhs4u86EdFofETqVXL5+YeUdFtp82P/TYLNFY3dFJfIYwyJg50TP01UH9+TOqa2W 1ttIBiXjlAKZFprgXkU0moAZjLUzNIpGWnBuLfTfuNphzAc2yeYsHm+JZ2ebotpSg3xqgZBTJPNNe 31p/JiAbYIx5+/tF1nfBnhcEoTahPaOou3wzixA00RT3Ou0fFidP32nxI+GyvrmfePxRYTLPT+gV6 vS7ulhMlwDB+54c4pnfmX2WqOVG+w==; Received: from bruce by momjian.us with local (Exim 4.96) (envelope-from ) id 1sgS45-003KFK-0Q; Tue, 20 Aug 2024 12:50:37 -0400 Date: Tue, 20 Aug 2024 12:50:37 -0400 From: Bruce Momjian To: Jelte Fennema-Nio Cc: "Fujii.Yuki@df.MitsubishiElectric.co.jp" , PostgreSQL-development , Robert Haas , Tom Lane , Stephen Frost , Andres Freund , Tomas Vondra , Julien Rouhaud , Daniel Gustafsson , vignesh C , Alexander Pyhalov Subject: Re: Partial aggregates pushdown Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Aug 20, 2024 at 10:07:32AM +0200, Jelte Fennema-Nio wrote: > On Thu, 15 Aug 2024 at 23:12, Bruce Momjian wrote: > > Third, I would like to show a more specific example to clarify what is > > being considered above. If we look at MAX(), we can have FDWs return > > the max for each FDW, and the coordinator can chose the highest value. > > This is the patch 1 listed above. These can return the > > pg_aggregate.aggtranstype data type using the pg_type.typoutput text > > output. > > > > The second case is for something like AVG(), which must return the SUM() > > and COUNT(), and we currently have no way to return multiple text values > > on the wire. For patch 0002, we have the option of creating functions > > that can do this and record them in new pg_attribute columns, or we can > > create a data type with these functions, and assign the data type to > > pg_aggregate.aggtranstype. > > > > Is that accurate? > > It's close to accurate, but not entirely. Patch 1 would actually > solves some AVG cases too, because some AVG implementations use an SQL > array type to store the transtype instead of an internal type. And by > using an SQL array type we *can* send multiple text values on the > wire. See below for a list of those aggregates: Okay, so we can do MAX easily, and AVG if the count can be represented as the same data type as the sum? Is that correct? Our only problem is that something like AVG(interval) can't use an array because arrays have to have the same data type for all array elements, and an interval can't represent a count? -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com Only you can decide what is important to you.