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 1sBpe4-001UsH-Ql for pgsql-hackers@arkaria.postgresql.org; Tue, 28 May 2024 05:45:14 +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 1sBpe4-008VW2-EQ for pgsql-hackers@arkaria.postgresql.org; Tue, 28 May 2024 05:45:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sBpe4-008VVt-0H for pgsql-hackers@lists.postgresql.org; Tue, 28 May 2024 05:45:12 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sBpe0-002KCn-9g for pgsql-hackers@postgresql.org; Tue, 28 May 2024 05:45:10 +0000 Received: from mail.postgrespro.ru (unknown [192.168.2.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: a.pyhalov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 18838E21108; Tue, 28 May 2024 08:45:04 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1716875104; bh=7exzPYNYuJVmcigTTpVM6uwsgPRAKoXzrTH/GubkdcQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:User-Agent: Message-ID:From; b=qtBgsXBHK7docy/ThM30Vof3Mbne/jVt5mt15QlvuU3uv1+m/XJC+agR7DUoiKhEX AClgtlzBD26Mv70Gh2Po/2OklobEhRpLsSo36tf/slcwUG8WpgQ8n7EC94IJRjXnbV vt372VvchMnEnkN54xI6ED5srvWM00shH3Wv2am8jDC/S0BqRA1B/Sw8Jjy4Nrb1Jn RXRBcJVT84J2UUkW6ynyDGRA+QJlKErzScGL6pO7CaO37wNH8KfPWnjUT5FTYL2mNa 3gXYXi7O+kdsUH9eozZqmWI2EuWBquDng41w8NjVK8Tn7acuuvh4HZdbxvOtAO7w9H BWl2JwPzLtQnA== MIME-Version: 1.0 Date: Tue, 28 May 2024 08:45:04 +0300 From: Alexander Pyhalov To: "Fujii.Yuki@df.MitsubishiElectric.co.jp" Cc: Robert Haas , PostgreSQL-development , Tom Lane , Bruce Momjian , Stephen Frost , Andres Freund , Tomas Vondra , Julien Rouhaud , Daniel Gustafsson , vignesh C Subject: Re: Partial aggregates pushdown In-Reply-To: References: <8175ddeb6d417d8a1f91e667fef77abf@postgrespro.ru> <4012625.1701120204@sss.pgh.pa.us> <31ab8f7b91cef6e837b3e31ea1e35a9a@postgrespro.ru> User-Agent: Roundcube Webmail/1.6.5 Message-ID: X-Sender: a.pyhalov@postgrespro.ru Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2024/05/28 01:37:00 #25308827 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Fujii.Yuki@df.MitsubishiElectric.co.jp писал(а) 2024-05-28 00:30: > Hi Mr. Pyhalov. > Hi. >> Found one more problem. You can fire partial aggregate over >> partitioned >> table, but convert_combining_aggrefs() will make non-partial copy, >> which >> leads to >> 'variable not found in subplan target list' error. > Thanks for the correction as well. > As you pointed out, > the original patch certainly had the potential to cause problems. > However, I could not actually reproduce the problem in cases such as > the following. > > Settings: > t(c1, c2) is a patitioned table whose partition key is c1. > t1, t2 are patitions of t and are partitioned table. > t11, t12: partitions of t1 and foreign table of postgres_fdw. > t21, t22: partitions of t2 and foreign table of postgres_fdw. > Query: > select c2 / 2, sum(c1) from t group by c2 / 2 order by 1 > > If you have a reproducible example, I would like to add it to > the regression test. > Do you have a reproducible example? > The fix was to set child_agg->agg_partial to orig_agg->agg_partial in convert_combining_aggrefs(), it's already in the patch, as well as the example - without this fix -- Check partial aggregate over partitioned table EXPLAIN (VERBOSE, COSTS OFF) SELECT avg(PARTIAL_AGGREGATE a), avg(a) FROM pagg_tab; fails with ERROR: variable not found in subplan target list -- Best regards, Alexander Pyhalov, Postgres Professional