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 1rgoZd-0085nj-RO for pgsql-general@arkaria.postgresql.org; Sun, 03 Mar 2024 16:20:26 +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 1rgoYd-001JV9-6k for pgsql-general@arkaria.postgresql.org; Sun, 03 Mar 2024 16:19:23 +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 1rgoYb-001JV1-CP for pgsql-general@lists.postgresql.org; Sun, 03 Mar 2024 16:19:23 +0000 Received: from fout8-smtp.messagingengine.com ([103.168.172.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rgoYV-002Zti-O7 for pgsql-general@postgresql.org; Sun, 03 Mar 2024 16:19:20 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id 7221E13800E5; Sun, 3 Mar 2024 11:19:12 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 03 Mar 2024 11:19:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1709482752; x=1709569152; bh=DfJzjKYBmf0DEh9Yvzn/u0NcjUKJmOawjbaJm9ut3V4=; b= BnFA54uE5ymk2zmSOURDcftYIiL4a4s2Gcl/clrb8jtd98rT6pxsMb2zrSHXTvb5 jRhar7mmdWPZnPpvtSnpqsLERBdH/lxvU0Sdo7YO3XXBqKbIJDwqTv6AcZPqEQik Hvai10GHFi+atWq2etZPowQNKfzPANw8YPZu0ClU0JN9VH3g1RIm8Y28vNh1XQZA aN1KFPwp97c9O/UYTvC2Pj31pl02Cj5KVSMwKoDB4rOhE9Bj8/bKCzDmFNhHbDet xeemB0K7UbZbSbgXU0xwTDxxbU0TKldf/HuwR8SuvPG4AZN1fBuStyCFkJyF7HL9 5NajR30mxAVvYaPmrnMlmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1709482752; x= 1709569152; bh=DfJzjKYBmf0DEh9Yvzn/u0NcjUKJmOawjbaJm9ut3V4=; b=b 8m+rFe8RD3PRszXbMondnx23VI7vNXEOvmjKwwzatnwflaKOhKnyRTO6BV2yw3Wu vKHPEiKhqxqzbX9cVfth/HazSXa7L5kDiS7Viymy6vENZG7U71ql0Kno2DpKe3qM WTux8qWDVAZB7wxVDDuorMA2+cE3IxUupl5a+ARg7UVKZnz2mYnTwr97PEphLc0y C1zO+R9ymNSzQ/B6vC0QzyUn41G8dUg4jNbeTv7uviCPqDNdKKRe5maJa69Wqmaq UKznZOyAd0eBVpZVUwBfgNVr6ydqkunKFxQV487qcbv7xcXjg40egq/KuZFpqDtH Be9oCiwVYyV33B3T15tWA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrheehgdekiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuggftrfgrthhtvghrnhepffelgeeifefgveduhedthfekuedtffejveegffegjeev tdehgfduieetfeehjeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 3 Mar 2024 11:19:11 -0500 (EST) Message-ID: <2b5c8483-ff9b-4fb2-8ed8-2e77e0f1f936@aklaver.com> Date: Sun, 3 Mar 2024 08:19:10 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: postgres_fdw aggregate pushdown for group by with expressions To: =?UTF-8?Q?Micha=C5=82_K=C5=82eczek?= , PG-General Mailing List References: <5FC17CB3-3048-455D-B638-B48949F78D06@kleczek.org> Content-Language: en-US From: Adrian Klaver In-Reply-To: <5FC17CB3-3048-455D-B638-B48949F78D06@kleczek.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/3/24 05:16, Michał Kłeczek wrote: > > >> On 3 Mar 2024, at 10:34, Michał Kłeczek wrote: >> >> Hi, >> >> I have the following foreign table: >> >> CREATE FOREIGN TABLE t1 ( >> grouping_column text, >> date_column date, >> whatever_data int >> ); >> >> The query is: >> >> SELECT >> sum(whatever_data) >> FROM >> t1 >> GROUP BY >> grouping_colulmn, extract(YEAR FROM date_column), extract(MONTH FROM date_column); >> >> From my (preliminary) testing postgres_fdw will not push down this aggregate query >> - it will happily push down query with only “grouping_column” or “grouping_column, date_column" in GROUP BY >> >> Is there a way to somehow push down the query with expressions in GROUP BY? > > I’ve performed some more tests and it seems expressions with “extract” function are not pushed down at all - > the WHERE criteria from the following query are not pushed down as well and filter is performed locally: > > SELECT > * > FROM > t1 > WHERE extract(YEAR FROM date_column) = 2023 > > I was under impression that “extract” meets all criteria for pushable expressions - looks like I am wrong? > > What would be the expression to achieve the same but such that postgres_fdw would push it down? What Postgres versions on both ends? What does select proname, prosrc, provolatile from pg_proc where proname = 'extract'; return? > > Thanks, > Michal > > > -- Adrian Klaver adrian.klaver@aklaver.com