Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1epFsc-0002FS-Nf for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Feb 2018 16:07:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1epFsb-0003aX-RF for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Feb 2018 16:07:25 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1epFsb-0003aN-Gt for pgsql-hackers@lists.postgresql.org; Fri, 23 Feb 2018 16:07:25 +0000 Received: from mx1.mailbox.org ([80.241.60.212]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1epFsY-0004Gx-8N for pgsql-hackers@postgresql.org; Fri, 23 Feb 2018 16:07:24 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (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 E5BF542BD1; Fri, 23 Feb 2018 17:07:18 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id UfgSDWlRgIYp; Fri, 23 Feb 2018 17:07:17 +0100 (CET) From: Antonin Houska To: Robert Haas cc: pgsql-hackers@postgresql.org Subject: Re: [HACKERS] WIP: Aggregation push-down In-reply-to: References: <9666.1491295317@localhost> <8160.1493369169@localhost> <29613.1502983342@localhost> <14577.1509723225@localhost> <18007.1513957437@localhost> <20239.1516971866@localhost> <13114.1517214722@localhost> Comments: In-reply-to Robert Haas message dated "Mon, 29 Jan 2018 09:43:49 -0500." MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 23 Feb 2018 17:08:03 +0100 Message-ID: <26256.1519402083@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Robert Haas wrote: > On Mon, Jan 29, 2018 at 3:32 AM, Antonin Houska wrote: > > I think of a variant of this: implement an universal function that test= s the > > binary values for equality (besides the actual arguments, caller would = have to > > pass info like typlen, typalign, typbyval for each argument, and cache = these > > for repeated calls) and set pg_proc(oprcode) to 0 wherever this functio= n is > > sufficient. Thus the problematic cases like numeric, citext, etc. would= be > > detected by their non-zero oprcode. >=20 > I don't think that's a good option, because we don't want int4eq to > have to go through a code path that has branches to support varlenas > and cstrings. Andres is busy trying to speed up expression evaluation > by removing unnecessary code branches; adding new ones would be > undoing that valuable work. I spent some more time thinking about this. What about adding a new strategy number for hash index operator classes, e.g. HTBinaryEqualStrategyNumber? F= or most types both HTEqualStrategyNumber and HTBinaryEqualStrategyNumber strat= egy would point to the same operator, but types like numeric would naturally ha= ve them different. Thus the pushed-down partial aggregation can only use the HTBinaryEqualStrategyNumber's operator to compare grouping expressions. In = the initial version (until we have useful statistics for the binary values) we = can avoid the aggregation push-down if the grouping expression output type has = the two strategies implemented using different functions because, as you noted upthread, grouping based on binary equality can result in excessive number = of groups. One open question is whether the binary equality operator needs a separate operator class or not. If an opclass cares only about the binary equality, = its hash function(s) can be a lot simpler. --=20 Antonin Houska Cybertec Sch=C3=B6nig & Sch=C3=B6nig GmbH Gr=C3=B6hrm=C3=BChlgasse 26, A-2700 Wiener Neustadt Web: https://www.cybertec-postgresql.com