Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQZUR-0006EB-G6 for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 14:32:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fQZUQ-0008Kn-1Z for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 14:32:42 +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.89) (envelope-from ) id 1fQZUP-0008Kd-MG for pgsql-general@lists.postgresql.org; Wed, 06 Jun 2018 14:32:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fQZUJ-00064S-44 for pgsql-general@postgresql.org; Wed, 06 Jun 2018 14:32:40 +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 w56EWRrG006458; Wed, 6 Jun 2018 10:32:27 -0400 From: Tom Lane To: Thomas Kellerer cc: pgsql-general@postgresql.org Subject: Re: Using distinct in an aggregate prevents parallel execution? In-reply-to: References: Comments: In-reply-to Thomas Kellerer message dated "Wed, 06 Jun 2018 14:41:25 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6456.1528295547.1@sss.pgh.pa.us> Date: Wed, 06 Jun 2018 10:32:27 -0400 Message-ID: <6457.1528295547@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Kellerer writes: > Is this a known limitation? Yes, unless somebody has done radical restructuring of the aggregation code while I wasn't looking. agg(DISTINCT ...) is currently implemented inside the Agg plan node, so it's an indivisible black box to everything else. That was a simple, minimum-code-footprint method for implementing the feature back when; but it's got lots of drawbacks, and one is that there's no reasonable way to parallelize. I'd anticipate that before we could even start to think of parallelizing, we'd have to split out the distinct-ification processing into a separate plan node. agg(... ORDER BY ...) has got the same problem, and it'd likely be advisable to fix that at the same time. regards, tom lane