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 1f0brr-0004w4-NK for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Mar 2018 23:49:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f0brp-0007Nh-Gw for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Mar 2018 23:49:33 +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.89) (envelope-from ) id 1f0brp-0007NX-9j for pgsql-hackers@lists.postgresql.org; Mon, 26 Mar 2018 23:49:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f0brm-0003nI-3y for pgsql-hackers@postgresql.org; Mon, 26 Mar 2018 23:49:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w2QNnOIU025813; Mon, 26 Mar 2018 19:49:24 -0400 From: Tom Lane To: David Rowley cc: Stephen Frost , Tomas Vondra , Andres Freund , PostgreSQL-development Subject: Re: Parallel Aggregates for string_agg and array_agg In-reply-to: <6538.1522096067@sss.pgh.pa.us> References: <24abe018-b3c6-2117-b5b9-39e660db00bd@2ndquadrant.com> <1b6ee15c-c218-761e-0120-c1ed438e2db2@2ndquadrant.com> <657be73a-a21d-0ae1-5c62-870afbdfddd4@2ndquadrant.com> <20180326022647.GL24540@tamriel.snowman.net> <20180326132009.GN24540@tamriel.snowman.net> <6538.1522096067@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 26 Mar 2018 16:27:47 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <25811.1522108164.1@sss.pgh.pa.us> Date: Mon, 26 Mar 2018 19:49:24 -0400 Message-ID: <25812.1522108164@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I wrote: > The main thing that remains undone is to get some test coverage --- > AFAICS, none of these new functions get exercised in the standard > regression tests. Oh, I thought of another thing that would need to get done, if we decide to commit this. array_agg_serialize/deserialize only work if the array element type has send/receive functions. The planner's logic to decide whether partial aggregation is possible doesn't look any deeper than whether the aggregate has serialize/deserialize, but I think we have to teach it that if it's these particular serialize/deserialize functions, it needs to check the array element type. Otherwise we'll get runtime failures if partial aggregation is attempted on array_agg(). This would not matter for any core datatypes, since they all have send/receive functions, but I imagine it's still pretty common for extension types not to. For my money it'd be sufficient to hard-code the test like if ((aggserialfn == F_ARRAY_AGG_SERIALIZE || aggdeserialfn == F_ARRAY_AGG_DESERIALIZE) && !array_element_type_has_send_and_recv(exprType(aggregate input))) Someday we might need more flexible testing, but that can be solved some other time. regards, tom lane