Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 2FB8E633407 for ; Wed, 28 Jul 2010 01:39:38 -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 27520-06 for ; Wed, 28 Jul 2010 04:39:31 +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 32B3363332C for ; Wed, 28 Jul 2010 01:39:31 -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 o6S4dRfV002240; Wed, 28 Jul 2010 00:39:27 -0400 (EDT) To: Alvaro Herrera cc: Peter Hussey , pgsql-performance Subject: Re: Questions on query planner, join types, and work_mem In-reply-to: <1280289550-sup-6155@alvh.no-ip.org> References: <18551.1280275502@sss.pgh.pa.us> <1280289550-sup-6155@alvh.no-ip.org> Comments: In-reply-to Alvaro Herrera message dated "Wed, 28 Jul 2010 00:01:51 -0400" Date: Wed, 28 Jul 2010 00:39:27 -0400 Message-ID: <2239.1280291967@sss.pgh.pa.us> From: Tom Lane 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: 201007/425 X-Sequence-Number: 39814 Alvaro Herrera writes: > Excerpts from Tom Lane's message of mar jul 27 20:05:02 -0400 2010: >> Well, the issue you're hitting is that the executor is dividing the >> query into batches to keep the size of the in-memory hash table below >> work_mem. The planner should expect that and estimate the cost of >> the hash technique appropriately, but seemingly it's failing to do so. > Hmm, I wasn't aware that hash joins worked this way wrt work_mem. Is > this visible in the explain output? As of 9.0, any significant difference between "Hash Batches" and "Original Hash Batches" would be a cue that the planner blew the estimate. For Peter's problem, we're just going to have to look to see if the estimated cost changes in a sane way between the small-work_mem and large-work_mem cases. regards, tom lane