X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id CAB6E9FA617 for ; Tue, 12 Sep 2006 21:40:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 29565-06 for ; Wed, 13 Sep 2006 00:40:08 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp1.ca.sophos.com (gw.ca.sophos.com [209.17.183.249]) by postgresql.org (Postfix) with ESMTP id 00BAC9FA50F for ; Tue, 12 Sep 2006 21:40:07 -0300 (ADT) Received: from smtp3.activestate.com (smtp3.activestate.com [192.168.3.19]) by smtp1.ca.sophos.com (8.12.10/8.12.10) with ESMTP id k8D0cfXE029408 for ; Tue, 12 Sep 2006 17:38:41 -0700 (envelope-from mischa@ca.sophos.com) Received: from [192.168.99.210] (mallet.ca.sophos.com [192.168.99.210]) by smtp3.ActiveState.com (8.13.4/8.13.4) with ESMTP id k8D0e3Di012176 for ; Tue, 12 Sep 2006 17:40:03 -0700 (envelope-from mischa@ca.sophos.com) Message-ID: <4507560F.9020906@ca.sophos.com> Date: Tue, 12 Sep 2006 17:51:27 -0700 From: Mischa Sandberg Reply-To: mischa@ca.sophos.com User-Agent: Thunderbird 1.5.0.5 (X11/20060719) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Bad plan for join to aggregate of join. References: <821wqiy0oc.fsf@mid.bfk.de> <45071FCC.8090509@ca.sophos.com> <3215.1158104550@sss.pgh.pa.us> In-Reply-To: <3215.1158104550@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200609/109 X-Sequence-Number: 20795 Tom Lane wrote: > Mischa Sandberg writes: >> can PG see that a join on an grouped-by field >> can be pushed down into the query as an indexable filter? > > No. The GROUP BY serves as a partial optimization fence. If you're > concerned about the speed of this query, I recommend making a different > view in which 'message' is joined inside the GROUP BY. Thanks.