Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id C5168632EE0 for ; Wed, 28 Jul 2010 01:02:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 41943-03 for ; Wed, 28 Jul 2010 04:02:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from spinlock.commandprompt.com (host-215.commandprompt.net [207.173.203.215]) by mail.postgresql.org (Postfix) with ESMTP id A1731632EC2 for ; Wed, 28 Jul 2010 01:02:09 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by spinlock.commandprompt.com (Postfix) with ESMTP id 30AA5348002; Tue, 27 Jul 2010 21:02:03 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at commandprompt.com Received: from spinlock.commandprompt.com ([127.0.0.1]) by localhost (spinlock.commandprompt.com.commandprompt.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LMujhUi4oJ5u; Tue, 27 Jul 2010 21:02:00 -0700 (PDT) Received: from alvh.no-ip.org (unknown [186.9.48.57]) by spinlock.commandprompt.com (Postfix) with ESMTPSA id 0C3063C5154; Tue, 27 Jul 2010 21:01:58 -0700 (PDT) Received: by alvh.no-ip.org (Postfix, from userid 1000) id 19C86438210; Wed, 28 Jul 2010 00:01:51 -0400 (CLT) Content-Type: text/plain; charset=UTF-8 Cc: Peter Hussey , pgsql-performance Subject: Re: Questions on query planner, join types, and work_mem From: Alvaro Herrera To: Tom Lane In-reply-to: <18551.1280275502@sss.pgh.pa.us> References: <18551.1280275502@sss.pgh.pa.us> Date: Wed, 28 Jul 2010 00:01:51 -0400 Message-Id: <1280289550-sup-6155@alvh.no-ip.org> User-Agent: Sup/git Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201007/423 X-Sequence-Number: 39812 Excerpts from Tom Lane's message of mar jul 27 20:05:02 -0400 2010: > Peter Hussey writes: > > 2) How is work_mem used by a query execution? > > 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. > Since you didn't provide EXPLAIN ANALYZE output, though, it's hard > to be sure. Hmm, I wasn't aware that hash joins worked this way wrt work_mem. Is this visible in the explain output? If it's something subtle (like an increased total cost), may I suggest that it'd be a good idea to make it explicit somehow in the machine-readable outputs?