X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id F3EF3329D27 for ; Wed, 22 Sep 2004 20:00:50 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 94406-02 for ; Wed, 22 Sep 2004 19:00:42 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id B9D91329E85 for ; Wed, 22 Sep 2004 20:00:43 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i8MJ0Z3V017292; Wed, 22 Sep 2004 15:00:35 -0400 (EDT) To: Greg Stark Cc: Dennis Bjorklund , Gaetano Mendola , pgsql-performance@postgresql.org, pgsql-patches@postgresql.org Subject: Re: [PERFORM] 7.4 vs 7.3 ( hash join issue ) In-reply-to: <87brfycfbf.fsf@stark.xeocode.com> References: <87sm9acih3.fsf@stark.xeocode.com> <14106.1095875794@sss.pgh.pa.us> <87brfycfbf.fsf@stark.xeocode.com> Comments: In-reply-to Greg Stark message dated "22 Sep 2004 14:46:12 -0400" Date: Wed, 22 Sep 2004 15:00:35 -0400 Message-ID: <17291.1095879635@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/252 X-Sequence-Number: 13114 Greg Stark writes: >> It would also be interesting to prefetch one row from the outer table and fall >> out immediately (without building the hash table) if the outer table is >> empty. This seems to require some contortion of the code though :-( > Why is it any more complicated than just moving the hash build down lower? Having to inject the consideration into ExecHashJoinOuterGetTuple seems messy to me. On reflection I'm not sure it would be a win anyway, for a couple of reasons. (1) Assuming that the planner has gotten things right and put the larger relation on the outside, the case of an empty outer relation and a nonempty inner one should rarely arise. (2) Doing this would lose some of the benefit from the optimization to detect an empty inner relation. If the outer subplan is a slow-start one (such as another hashjoin), it would lose a lot of the benefit :-( regards, tom lane