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 ECEE19DCDA0 for ; Thu, 12 Jan 2006 08:34:55 -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 25055-10 for ; Thu, 12 Jan 2006 08:34:58 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.barettadeit.com (unknown [213.255.109.130]) by postgresql.org (Postfix) with ESMTP id 296989DCA35 for ; Thu, 12 Jan 2006 08:34:53 -0400 (AST) Received: from [10.0.0.10] (alex.barettalocal.com [10.0.0.10]) by mail.barettadeit.com (Postfix) with ESMTP id 6F5C4112E1F; Thu, 12 Jan 2006 13:38:56 +0100 (CET) Message-ID: <43C64CFB.9030504@barettadeit.com> Date: Thu, 12 Jan 2006 13:35:07 +0100 From: Alessandro Baretta User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-1?Q?Ott=F3_Havasv=F6lgyi?= Cc: pgsql-performance@postgresql.org Subject: Re: Throwing unnecessary joins away References: <34608c0c0601120418n1af567b9n@mail.gmail.com> In-Reply-To: <34608c0c0601120418n1af567b9n@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200601/152 X-Sequence-Number: 16630 Ottó Havasvölgyi wrote: > Hi all, > > Is PostgreSQL able to throw unnecessary joins? > For example I have two tables, and I join then with their primary keys, > say type of bigint . In this case if I don't reference to one of the > tables anywhere except the join condition, then the join can be eliminated. > Or if I do a "table1 left join table2 (table1.referer=table2.id)" (N : > 1 relationship), and I don't reference table2 anywhere else, then it is > unnecessary. It cannot possibly remove "unnecessary joins", simply because the join influences whether a tuple in the referenced table gets selected and how many times. Alex -- ********************************************************************* http://www.barettadeit.com/ Baretta DE&IT A division of Baretta SRL tel. +39 02 370 111 55 fax. +39 02 370 111 54 Our technology: The Application System/Xcaml (AS/Xcaml) The FreerP Project