Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 85E10633122 for ; Sun, 19 Apr 2009 20:31:57 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 73698-09 for ; Sun, 19 Apr 2009 20:31:49 -0300 (ADT) 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 B0BA96330F1 for ; Sun, 19 Apr 2009 20:31:55 -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 n3JNVq0p012402; Sun, 19 Apr 2009 19:31:52 -0400 (EDT) To: Kris Jurka cc: pgsql-performance@postgresql.org Subject: Re: No hash join across partitioned tables? In-reply-to: References: <7163.1239923531@sss.pgh.pa.us> Comments: In-reply-to Kris Jurka message dated "Thu, 16 Apr 2009 21:02:04 -0400" Date: Sun, 19 Apr 2009 19:31:51 -0400 Message-ID: <12401.1240183911@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.362 tagged_above=0 required=5 tests=AWL=-0.048, SUBJECT_FUZZY_TION=0.41 X-Spam-Level: X-Archive-Number: 200904/296 X-Sequence-Number: 33663 Kris Jurka writes: > The real problem is getting reasonable stats to pass through the partition > Append step, so it can make a reasonable estimate of the join output size. I dug around a bit and concluded that the lack of stats for the Append relation is indeed the main problem. It's not so much the bad join size estimate (although that could hurt for cases where you need to join this result to another table). Rather, it's that the planner is deliberately biased against picking hash joins in the absence of stats for the inner relation. Per the comments for estimate_hash_bucketsize: * If no statistics are available, use a default estimate of 0.1. This will * discourage use of a hash rather strongly if the inner relation is large, * which is what we want. We do not want to hash unless we know that the * inner rel is well-dispersed (or the alternatives seem much worse). While we could back off the default a bit here, I think it'd be better to fix it by not punting on the stats-for-append-relations problem. That doesn't seem like material for 8.4 at this point, though. regards, tom lane