X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 098C95280B for ; Wed, 6 Jul 2005 07:00:39 -0300 (ADT) 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 49173-04 for ; Wed, 6 Jul 2005 10:00:36 +0000 (GMT) Received: from samson.futurequest.net (samson.futurequest.net [69.5.27.3]) by svr1.postgresql.org (Postfix) with SMTP id 39B3252806 for ; Wed, 6 Jul 2005 07:00:34 -0300 (ADT) Received: (qmail 24291 invoked from network); 6 Jul 2005 10:00:36 -0000 Received: from ryuuguu.com (ryuuguu.com [69.5.27.98]) by samson.futurequest.net ([69.5.27.3]); 06 Jul 2005 10:00:35 -0000 Received: from 165.76.205.21 ([165.76.205.21]) by ryuuguu.com ([69.5.27.98]) with ESMTP via TCP; 06 Jul 2005 10:00:35 -0000 To: pgsql-sql@postgresql.org Subject: left joins Date: Wed, 06 Jul 2005 19:01:54 +0900 From: "Grant Morgan" Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: User-Agent: Opera M2/8.01 (Linux, build 1204) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.556 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, RCVD_NUMERIC_HELO X-Spam-Level: * X-Archive-Number: 200507/30 X-Sequence-Number: 22008 I am having a problem with left joins in Postgresql.(probably my misunderstanding of left joins) My first Query returns 70,000 select count(*) from h where h.tn > 20 and h.tn < 30 my left join returns only 34,000 select count(*) from h left join p using (r,pos) where h.tn > 20 and h.tn < 30 and p.r_order=1 since it is a left join I though I should get a number no smaller in the left join than the original unjoined query. It seems to be acting like an inner join. Both of these are tables not views and both have hash indices on r column. I have tried left joins, right joins , and both using and on , nothing seems make a difference. Questions 1)should a left join return atleast as many rows as the unjoined left table? 2)am I doing something wrong above? 3)If am not doing anything wrong is this postgresql problem and is there a work around? Cheers, Grant