Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dqIVm-0002iB-AM for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Sep 2017 12:35:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dqIVl-0002mg-LN for pgsql-hackers@arkaria.postgresql.org; Fri, 08 Sep 2017 12:35:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dqIVl-0002mW-1Z for pgsql-hackers@postgresql.org; Fri, 08 Sep 2017 12:35:53 +0000 Received: from mx1.mailbox.org ([80.241.60.212]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dqIVh-00069S-5F for pgsql-hackers@postgresql.org; Fri, 08 Sep 2017 12:35:52 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id 94BDC437D5 for ; Fri, 8 Sep 2017 14:35:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id xvkB94y3-tBH for ; Fri, 8 Sep 2017 14:35:45 +0200 (CEST) From: Antonin Houska To: pgsql-hackers@postgresql.org Subject: Re: WIP: Aggregation push-down In-reply-to: References: <9666.1491295317@localhost> <8160.1493369169@localhost> <29613.1502983342@localhost> Comments: In-reply-to Jeevan Chalke message dated "Thu, 07 Sep 2017 14:44:31 +0530." MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Fri, 08 Sep 2017 14:36:03 +0200 Message-ID: <22851.1504874163@localhost> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Jeevan Chalke wrote: > 1. > + if (aggref->aggvariadic || > + aggref->aggdirectargs || aggref->aggorder || > + aggref->aggdistinct || aggref->aggfilter) >=20 > I did not understand, why you are not pushing aggregate in above cases? > Can you please explain? Currently I'm trying to implement infrastructure to propagate result of partial aggregation from base relation or join to the root of the join tree and to use these as input for the final aggregation. Some special cases are disabled because I haven't thought about them enough so far. Some of these restrictions may be easy to relax, others may be hard. I'll get back to them at some point. > 2. "make check" in contrib/postgres_fdw crashes. >=20 > SELECT COUNT(*) FROM ft1 t1; > ! server closed the connection unexpectedly > ! This probably means the server terminated abnormally > ! before or while processing the request. > ! connection to server was lost >=20 > From your given setup, if I wrote a query like: > EXPLAIN VERBOSE SELECT count(*) FROM orders_0; > it crashes. >=20 > Seems like missing few checks. Please consider this a temporary limitation. > 3. In case of pushing partial aggregation on the remote side, you use sch= ema > named "partial", I did not get that change. If I have AVG() aggregate, > then I end up getting an error saying > "ERROR: schema "partial" does not exist". Attached to his email is an extension that I hacked quickly at some point, = for experimental purposes only. It's pretty raw but may be useful if you just w= ant to play with it. > 4. I am not sure about the code changes related to pushing partial > aggregate on the remote side. Basically, you are pushing a whole aggregate > on the remote side and result of that is treated as partial on the > basis of aggtype =3D transtype. But I am not sure that is correct unless > I miss something here. The type may be same but the result may not. You're right. I mostly used sum() and count() in my examples but these are special cases. It should also be checked whether aggfinalfn exists or not. I'll fix it, thanks. > 5. There are lot many TODO comments in the patch-set, are you working > on those? Yes. I wasn't too eager to complete all the TODOs soon because reviews of t= he partch may result in a major rework. And if large parts of the code will ha= ve to be wasted, some / many TODOs will be gone as well. > Thanks >=20 > On Thu, Aug 17, 2017 at 8:52 PM, Antonin Houska wrote: >=20 > Antonin Houska wrote: >=20 > > Antonin Houska wrote: > > > > > This is a new version of the patch I presented in [1]. > > > > Rebased. > > > > cat .git/refs/heads/master > > b9a3ef55b253d885081c2d0e9dc45802cab71c7b >=20 > This is another version of the patch. >=20 > Besides other changes, it enables the aggregation push-down for postgres= _fdw, > although only for aggregates whose transient aggregation state is equal = to the > output type. For other aggregates (like avg()) the remote nodes will hav= e to > return the transient state value in an appropriate form (maybe bytea typ= e), > which does not depend on PG version. >=20 > shard.tgz demonstrates the typical postgres_fdw use case. One query show= s base > scans of base relation's partitions being pushed to shard nodes, the oth= er > pushes down a join and performs aggregation of the join result on the re= mote > node. Of course, the query can only references one particular partition,= until > the "partition-wise join" [1] patch gets committed and merged with this = my > patch. >=20 > One thing I'm not sure about is whether the patch should remove > GetForeignUpperPaths function from FdwRoutine, which it essentially makes > obsolete. Or should it only be deprecated so far? I understand that > deprecation is important for "ordinary SQL users", but FdwRoutine is an > interface for extension developers, so the policy might be different. >=20 > [1] https://commitfest.postgresql.org/14/994/ >=20 > Any feedback is appreciated. >=20 > -- > Antonin Houska > Cybertec Sch=C3=B6nig & Sch=C3=B6nig GmbH > Gr=C3=B6hrm=C3=BChlgasse 26 > A-2700 Wiener Neustadt > Web: http://www.postgresql-support.de, http://www.cybertec.at >=20 > -- > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers >=20 > --=20 > Jeevan Chalke > Principal Software Engineer, Product Development > EnterpriseDB Corporation > The Enterprise PostgreSQL Company >=20 >=20 --=20 Antonin Houska Cybertec Sch=C3=B6nig & Sch=C3=B6nig GmbH Gr=C3=B6hrm=C3=BChlgasse 26 A-2700 Wiener Neustadt Web: http://www.postgresql-support.de, http://www.cybertec.at --=-=-= Content-Type: application/x-gzip Content-Disposition: attachment; filename=partial.tgz Content-Transfer-Encoding: base64 H4sIAKmIslk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bcb/wejEr1fAFAAAA== --=-=-= Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --=-=-=--