Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 386C5B600DA for ; Mon, 6 Jun 2011 21:18:03 -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 18052-04 for ; Tue, 7 Jun 2011 00:17:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iw0-f174.google.com (mail-iw0-f174.google.com [209.85.214.174]) by mail.postgresql.org (Postfix) with ESMTP id 75016B60405 for ; Mon, 6 Jun 2011 21:16:19 -0300 (ADT) Received: by iwn34 with SMTP id 34so3564206iwn.19 for ; Mon, 06 Jun 2011 17:16:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:references:in-reply-to:subject:date :message-id:mime-version:content-type:content-transfer-encoding :x-mailer:thread-index:content-language; bh=cnPI2U3yzARaP6JZl/XupT4/VoAEiXz01Y1TpzO7F4Y=; b=dEywWPUi3a/6QKYxeOEmXl6JZ3EX91YsUrgQc5A8r8GHjmOy8xIjJXKSA3VPGxrKVt m4JuvyAoCFjKbgIPEAp74rnHVLO/8AoS2L50kX/zdmXR070YiGs3rcloUPQkHJSlbjAg rxyqSebrzJc+g6PtUL7P9wVuzf8S8PB4BeyuU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:references:in-reply-to:subject:date:message-id :mime-version:content-type:content-transfer-encoding:x-mailer :thread-index:content-language; b=gadjWjuTAwKnIgKN8sdAVdaclOllZi/+1p9VC0tU+6Zn8ezwP0Rhdt2dU9OohwoB+D C/IcXb3Cn97spHtN9jLYASqNtoHq56LKueum37ef9AiWGcU0GI1fqOMEgdfUFxSxuxhQ 3dDnCZfa7owfEPmz3I44L1O2wkvnRlG/Zg0As= Received: by 10.42.157.138 with SMTP id d10mr9313955icx.490.1307405779255; Mon, 06 Jun 2011 17:16:19 -0700 (PDT) Received: from Duality (65-101-230-181.hlrn.qwest.net [65.101.230.181]) by mx.google.com with ESMTPS id hp8sm3123408icc.23.2011.06.06.17.16.17 (version=SSLv3 cipher=OTHER); Mon, 06 Jun 2011 17:16:18 -0700 (PDT) From: "mark" To: "'Craig Ringer'" Cc: References: <4DED5DB5.4030309@postnewspapers.com.au> In-Reply-To: <4DED5DB5.4030309@postnewspapers.com.au> Subject: Re: not exits slow compared to not in. (nested loops killing me) Date: Mon, 6 Jun 2011 18:16:12 -0600 Message-ID: <005701cc24a8$1cdf1770$569d4650$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: Acwkno8HG0EkWLlWT6CCACcb6O1iZAAB6R/A Content-Language: en-us X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201106/42 X-Sequence-Number: 43975 > -----Original Message----- > From: Craig Ringer [mailto:craig@postnewspapers.com.au] > Sent: Monday, June 06, 2011 5:08 PM > To: mark > Cc: pgsql-performance@postgresql.org > Subject: Re: [PERFORM] not exits slow compared to not in. (nested loops > killing me) > > On 06/07/2011 04:38 AM, mark wrote: > > > NOT EXISTS (with 64MB of work_mem) > > http://explain.depesz.com/s/EuX > > Hash Anti Join (cost=443572.19..790776.84 rows=1 width=1560) > (actual time=16337.711..50358.487 rows=2196299 loops=1) > > Note the estimated vs actual rows. Either your stats are completely > ridiculous, or the planner is confused. I am starting to think the planner might be confused in 9.0.2. I got a reasonable query time, given resource constraints, on a very small VM on my laptop running 9.0.4. I am going to work on getting the vm I was using to test this with up to 9.0.4 and test again. There is a note in the 9.0.4 release notes " Improve planner's handling of semi-join and anti-join cases (Tom Lane)" Not sure that is the reason I got a much better outcome with a much smaller vm. But once I do some more testing I will report back. > > What are your stats target levels? Have you tried increasing the stats > levels on the table(s) or at least column(s) affected? Or tweaking > default_statistics_target if you want to use a bigger hammer? Will try that as well. Currently the default stat target is 100. Will try at 250, and 500 and report back. > > Is autovacuum being allowed to do its work and regularly ANALYZE the > database? Does an explicit 'ANALYZE' help? Auto vac is running, I have explicitly vacuum & analyzed the whole db. That didn't change anything. > > -- > Craig Ringer