Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id B8E3C2E0089 for ; Tue, 18 Mar 2008 02:48:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 14350-09 for ; Tue, 18 Mar 2008 02:48:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from smtp102.biz.mail.mud.yahoo.com (smtp102.biz.mail.mud.yahoo.com [68.142.200.237]) by postgresql.org (Postfix) with SMTP id C12C62E0039 for ; Tue, 18 Mar 2008 02:48:37 -0300 (ADT) Received: (qmail 65706 invoked from network); 18 Mar 2008 05:48:36 -0000 Received: from unknown (HELO ?192.168.5.128?) (ramayer@forensiclogic.com@76.203.171.164 with plain) by smtp102.biz.mail.mud.yahoo.com with SMTP; 18 Mar 2008 05:48:36 -0000 X-YMail-OSG: rQuAMykVM1mbF7ULTMy1D7TUyVCDLXLjJRkUC21.D8ulhL98jkSSQGCeusZM3HeheNRJk4Yang-- X-Yahoo-Newman-Property: ymail-3 Message-ID: <47DF57B3.9090206@cheapcomplexdevices.com> Date: Mon, 17 Mar 2008 22:48:35 -0700 From: Ron Mayer User-Agent: Thunderbird 2.0.0.12 (X11/20080227) MIME-Version: 1.0 To: Tom Lane CC: Bruce Momjian , Ron Mayer , pgsql-performance@postgresql.org Subject: Re: TB-sized databases References: <200803172347.m2HNlCD29489@momjian.us> <4005.1205800130@sss.pgh.pa.us> In-Reply-To: <4005.1205800130@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/366 X-Sequence-Number: 29320 Tom Lane wrote: > Bruce Momjian writes: >> I have _not_ added a TODO for this item. Let me know if one is needed. > > Please do, I think it's an open issue. > > * Consider Cartesian joins when both relations are needed to form an > indexscan qualification for a third relation > Would another possible condition for considering Cartesian joins be be: * Consider Cartesian joins when a unique constraint can prove that at most one row will be pulled from one of the tables that would be part of this join? In the couple cases where this happened to me it was in queries on a textbook star schema like this: select * from fact join dim1 using (dim1_id) join dim2 using (dim2_id) where dim1.value = 'something' and dim2.valuex = 'somethingelse' and dim2.valuey = 'more'; and looking up all the IDs before hitting the huge fact table. Often in these cases the where clause on the dimension tables are on values with a unique constraint. If I understand right - if the constraint can prove it'll return at most 1 row - that means the cartesian join is provably safe from blowing up. Not sure if that's redundant with the condition you mentioned, or if it's yet a separate condition where we might also want to consider cartesian joins. Ron M