Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 629C81337B49 for ; Tue, 19 Oct 2010 11:22:53 -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 35685-02 for ; Tue, 19 Oct 2010 14:22:46 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lpo-relay-04.vmsinfo.com (lpo-relay-04.vmsinfo.com [216.169.137.115]) by mail.postgresql.org (Postfix) with ESMTP id 21B871336DB6 for ; Tue, 19 Oct 2010 11:22:45 -0300 (ADT) X-IronPort-AV: E=Sophos;i="4.57,350,1283745600"; d="scan'208";a="26380870" Received: from unknown (HELO lpo-mailbox-01.vmsinfo.com) ([216.169.137.251]) by lpo-relay-04.vmsinfo.com with ESMTP; 19 Oct 2010 10:22:45 -0400 Received: from [10.101.43.35] (unknown [216.169.135.235]) by lpo-mailbox-01.vmsinfo.com (Postfix) with ESMTP id 5EC537D00D; Tue, 19 Oct 2010 10:22:45 -0400 (EDT) Message-ID: <4CBDA9B2.2040807@vmsinfo.com> Date: Tue, 19 Oct 2010 10:22:42 -0400 From: Mladen Gogala Organization: VMS User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: Scott Carey CC: Tom Lane , "pgsql-performance@postgresql.org Performance" Subject: Re: HashJoin order, hash the large or small table? Postgres likes to hash the big one, why? References: <1532.1287459825@sss.pgh.pa.us> <56326542-EFD1-493D-BD35-CD67FB004CF4@richrelevance.com> In-Reply-To: <56326542-EFD1-493D-BD35-CD67FB004CF4@richrelevance.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 201010/305 X-Sequence-Number: 40723 Scott Carey wrote: > > If the cost to hash is 1200493, and it needs to probe the hash 20241 times, why would the total cost be 631471410? The cost to probe can't be that big! A cost of 500 to probe and join? > Why favor hashing the large table and probing with the small values rather than the other way around? > > May I ask a stupid question: how is the query cost calculated? What are the units? I/O requests? CPU cycles? Monopoly money? -- Mladen Gogala Sr. Oracle DBA 1500 Broadway New York, NY 10036 (212) 329-5251 http://www.vmsinfo.com The Leader in Integrated Media Intelligence Solutions