Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id ADDE81337C03 for ; Mon, 2 May 2011 13:26:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 97181-04-2 for ; Mon, 2 May 2011 16:26:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id B74B01338007 for ; Mon, 2 May 2011 13:04:59 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Mon, 02 May 2011 11:04:58 -0500 Message-Id: <4DBE8FD8020000250003D101@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Mon, 02 May 2011 11:04:56 -0500 From: "Kevin Grittner" To: "Tom Lane" ,"Wayne Conrad" Cc: Subject: Re: 8.4.7, incorrect estimate References: <4DBB024B.5050500@databill.com> <4DBAC75C020000250003D06B@gw.wicourts.gov> <4DBEAF7B.1060409@yagni.com><4DBEAF7B.1060409@yagni.com> <21729.1304349118@sss.pgh.pa.us> In-Reply-To: <21729.1304349118@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/18 X-Sequence-Number: 43527 Tom Lane wrote: > Wayne Conrad writes: >> Total runtime: 244572.432 ms > I'll take a look at fixing that, but not sure if it'll be > reasonable to back-patch or not. In the meantime, you need to > look into restructuring the query to avoid nesting the EXISTS > probes, if possible. Wayne, I think your best bet at this point may be to just (INNER) JOIN the three tables, and if there is a possibility of duplicates to use SELECT DISTINCT. -Kevin