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 1fQdrR-0000Vg-JJ for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 19:12:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fQdrQ-00060r-F3 for pgsql-general@arkaria.postgresql.org; Wed, 06 Jun 2018 19:12:44 +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 1fQdrQ-00060V-72 for pgsql-general@lists.postgresql.org; Wed, 06 Jun 2018 19:12:44 +0000 Received: from [195.159.176.226] (helo=blaine.gmane.org) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fQdrO-00026w-4i for pgsql-general@postgresql.org; Wed, 06 Jun 2018 19:12:43 +0000 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fQdpF-0002AU-9n for pgsql-general@postgresql.org; Wed, 06 Jun 2018 21:10:29 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-general@postgresql.org From: Thomas Kellerer Subject: Re: Using distinct in an aggregate prevents parallel execution? Date: Wed, 6 Jun 2018 21:12:34 +0200 Lines: 23 Message-ID: <8e89b5e2-555d-778e-c40b-3b7c8ded5d4e@gmx.net> References: <6457.1528295547@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@blaine.gmane.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.5.666 In-Reply-To: <6457.1528295547@sss.pgh.pa.us> Content-Language: de-DE X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.159.176.226 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tom Lane schrieb am 06.06.2018 um 16:32: > 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. Thansk for the explanation.