Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A694C9F9597 for ; Sun, 4 Nov 2007 09:15:03 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 96707-02 for ; Sun, 4 Nov 2007 09:14:58 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from bay0-omc2-s10.bay0.hotmail.com (bay0-omc2-s10.bay0.hotmail.com [65.54.246.146]) by postgresql.org (Postfix) with ESMTP id B08529F959D for ; Sun, 4 Nov 2007 09:14:58 -0400 (AST) Received: from BAY138-W43 ([64.4.49.78]) by bay0-omc2-s10.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 4 Nov 2007 05:14:52 -0800 Message-ID: Content-Type: multipart/alternative; boundary="_b3970b20-e445-4eab-8fce-235a436d9cf5_" X-Originating-IP: [128.10.9.112] From: Ehab Galal To: "pgsql-sql@postgresql.org" Subject: omitting redundant join predicate Date: Sun, 4 Nov 2007 08:14:51 -0500 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 04 Nov 2007 13:14:52.0011 (UTC) FILETIME=[AF289BB0:01C81EE4] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=BAYES_50=0.001, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200711/4 X-Sequence-Number: 29532 --_b3970b20-e445-4eab-8fce-235a436d9cf5_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable =0A= =0A= I tried the following query =0A= =0A= =0A= =0A= explain select * =0A= =0A= from t1, t2, t3 =0A= =0A= where t1.f <=3D t2.f=0A= =0A= and t2.f <=3D t3.f=0A= =0A= and t1.f <=3D t3.f;=0A= =0A= =0A= =0A= And that's what I got:=0A= =0A= =0A= =0A= Nested Loop (cost=3D0.00..3.15 rows=3D1 width=3D368)=0A= =0A= Join Filter:=0A= (("outer".f <=3D "inner".f) AND ("inner".f <=3D=0A= "outer".f))=0A= =0A= -> Nested Loop (cost=3D0.00..2.10 rows=3D1 width=3D218)=0A= =0A= Join Filter:=0A= ("outer".f <=3D "inner".f)=0A= =0A= -> Seq Scan on t1 (cost=3D0.00..1.01 rows=3D1 width=3D146)=0A= =0A= -> Seq Scan on t3 (cost=3D0.00..1.04 rows=3D4 width=3D72)=0A= =0A= -> Seq Scan on t2 (cost=3D0.00..1.02 rows=3D2 width=3D150)=0A= =0A= =0A= =0A= =0A= =0A= I was wondering if there is a=0A= way to omit the redundant join predicate.=0A= =0A= =0A= =0A= Thanks,=0A= =0A= --h=0A= =0A= _________________________________________________________________ Windows Live Hotmail and Microsoft Office Outlook =96 together at last. =A0= Get it now. http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=3DCL10062= 6971033= --_b3970b20-e445-4eab-8fce-235a436d9cf5_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
=0A= =0A=

I tried the following query

=0A= =0A=

 

=0A= =0A=

explain select *

=0A= =0A=

from t1, t2, t3

=0A= =0A=

where t1.f <=3D t2.f

=0A= =0A=

  a= nd t2.f <=3D t3.f

=0A= =0A=

  a= nd t1.f <=3D t3.f;

=0A= =0A=

 

=0A= =0A=

And that's what I got:

=0A= =0A=

 

=0A= =0A=

Nested Lo= op  (cost=3D0.00..3.15 rows=3D1 wi= dth=3D368)

=0A= =0A=

   Join Filter:=0A= (("outer".f <=3D "inner".f) AND ("inner".f <=3D=0A= "outer".f))

=0A= =0A=

   ->  Nested Loop=   (cost=3D0.00..2.10 rows=3D1 widt= h=3D218)

=0A= =0A=

  &nb= sp;      Join Filter:=0A= ("outer".f <=3D "inner".f)

=0A= =0A=

  &nb= sp;      ->  Seq Scan on t1  (cost=3D0.00..1.01 rows=3D1 = width=3D146)

=0A= =0A=

  &nb= sp;      ->  Seq Scan on t3  (cost=3D0.00..1.04 rows=3D4 = width=3D72)

=0A= =0A=

   ->  Seq Scan on t2&nb= sp; (cost=3D0.00..1.02 rows=3D2 width=3D150)

= =0A= =0A=

 

=0A= =0A=

 

=0A= =0A=

I = was wondering if there is a=0A= way to omit the redundant join predicate.

=0A= =0A=

 

=0A= =0A=

Th= anks,

=0A= =0A=

--= h

=0A= =0A=


Windows Live Hotmail and Microsoft Office Outlook =96 tog= ether at last. Get it now! = --_b3970b20-e445-4eab-8fce-235a436d9cf5_--