X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C3EB19DCDCA for ; Thu, 12 Jan 2006 13:03:07 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97927-03 for ; Thu, 12 Jan 2006 13:03:05 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from koolancexeon.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 87CB19DCDC5 for ; Thu, 12 Jan 2006 13:03:04 -0400 (AST) Received: mail.g2switchworks.com 10.10.1.8 from 10.10.1.37 10.10.1.37 via HTTP with MS-WebStorage 6.5.6944 Received: from state.g2switchworks.com by mail.g2switchworks.com; 12 Jan 2006 11:03:02 -0600 Subject: Re: Throwing unnecessary joins away From: Scott Marlowe To: =?ISO-8859-1?Q?Ott=F3_Havasv=F6lgyi?= Cc: pgsql-performance@postgresql.org In-Reply-To: <34608c0c0601120900l7d26073dp@mail.gmail.com> References: <34608c0c0601120418n1af567b9n@mail.gmail.com> <43C64CFB.9030504@barettadeit.com> <34608c0c0601120541wd910da3s@mail.gmail.com> <5269.1137081233@sss.pgh.pa.us> <34608c0c0601120900l7d26073dp@mail.gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-Id: <1137085382.3959.16.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Thu, 12 Jan 2006 11:03:02 -0600 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.116 required=5 tests=[AWL=0.115, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 0.116 X-Spam-Level: X-Archive-Number: 200601/159 X-Sequence-Number: 16637 On Thu, 2006-01-12 at 11:00, Ott=C3=B3 Havasv=C3=B6lgyi wrote: > Hi, >=20 > I think it would be sufficient only for views. In other cases the > programmer can optimize himself. But a view can be a join of other > tables, and it is not sure that all of them are always needed. It all > depends on what I select from the view. The idea that you could throw away joins only works for outer joins.=20 I.e. if you did: select a.x, a.y, a.z from a left join b (on a.id=3Db.aid)=20 then you could throw away the join to b. But if it was a regular inner join then you couldn't know whether or not you needed to join to b without actually joining to b...