Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 2503BB5DDBF for ; Sun, 4 Sep 2011 19:15:22 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 42139-08 for ; Sun, 4 Sep 2011 22:15:14 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id B15FEB5DC33 for ; Sun, 4 Sep 2011 19:15:14 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p84MExx9008732; Sun, 4 Sep 2011 18:15:01 -0400 (EDT) To: Mark Kirkwood cc: PGSQL Performance Subject: Re: 8.4 optimization regression? In-reply-to: <4E601B2F.30107@catalyst.net.nz> References: <4E5331FF.3000900@catalyst.net.nz> <15708.1314155740@sss.pgh.pa.us> <4E5DCFA4.5090806@catalyst.net.nz> <5156.1314829311@sss.pgh.pa.us> <26940.1314918836@sss.pgh.pa.us> <4E6012E2.2000004@catalyst.net.nz> <4E601B2F.30107@catalyst.net.nz> Comments: In-reply-to Mark Kirkwood message dated "Fri, 02 Sep 2011 11:54:23 +1200" Date: Sun, 04 Sep 2011 18:14:59 -0400 Message-ID: <8731.1315174499@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201109/22 X-Sequence-Number: 44798 Mark Kirkwood writes: > While this is still fresh in your mind, a couple of additional anti join > queries are still managing to sneak past estimation: Yeah, those are estimating that all the outer rows have join partners, because there are more distinct values in the sub-select than there are in the outer relation. AFAICS there are not any errors in the statistics, it's just that the estimation rule falls down here. If you've heard of a better estimator for semijoin/antijoin selectivity, I'm all ears. The best idea I have at the moment is to put an arbitrary upper limit on the estimated selectivity, but that would be, well, arbitrary. regards, tom lane