Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 71A0B133740B for ; Fri, 4 Feb 2011 22:51:12 -0400 (AST) 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 19347-02 for ; Sat, 5 Feb 2011 02:51:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 493261337BA0 for ; Fri, 4 Feb 2011 22:51:04 -0400 (AST) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PlYEq-0001Zt-N9 for pgsql-performance@postgresql.org; Sat, 05 Feb 2011 03:51:04 +0100 Received: from cpe-188-129-112-64.dynamic.amis.hr ([188.129.112.64]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Feb 2011 03:51:04 +0100 Received: from ivoras by cpe-188-129-112-64.dynamic.amis.hr with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 05 Feb 2011 03:51:04 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org From: Ivan Voras Subject: Re: Query performance with disabled hashjoin and mergejoin Date: Sat, 05 Feb 2011 03:50:50 +0100 Lines: 28 Message-ID: References: <4D4C10EA.2080901@2ndquadrant.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: cpe-188-129-112-64.dynamic.amis.hr User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.12) Gecko/20101102 Thunderbird/3.1.6 In-Reply-To: <4D4C10EA.2080901@2ndquadrant.com> 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: 201102/231 X-Sequence-Number: 42369 On 04/02/2011 15:44, Greg Smith wrote: > Ivan Voras wrote: >> The "vanilla" plan, with default settings is: > > Pause here for a second: why default settings? A default PostgreSQL > configuration is suitable for systems with about 128MB of RAM. Since you > say you have "good enough hardware", I'm assuming you have a bit more > than that. The first things to try here are the list at > http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server ; your bad > query here looks like it might benefit from a large increase to > effective_cache_size, and possibly an increase to work_mem as well. Your > "bad" plan here is doing a lot of sequential scans instead of indexed > lookups, which makes me wonder if the change in join types you're > forcing isn't fixing that part as a coincidence. My earlier message didn't get through so here's a repeat: Sorry for the confusion, by "default settings" I meant "planner default settings" not generic shared buffers, wal logs, work memory etc. - which are adequately tuned. > Note that the estimated number of rows coming out of each form of plan > is off by a factor of about 200X, so it's not that the other plan type > is better estimating anything. Any ideas how to fix the estimates? Or will I have to simulate hints by issuing "set enable_hashjoin=f; set enable_mergejoin=f;" for this query? :)