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 C3F009DCDB5 for ; Thu, 12 Jan 2006 09:41:28 -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 41197-01 for ; Thu, 12 Jan 2006 09:41:31 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.201]) by postgresql.org (Postfix) with ESMTP id 443269DCD9A for ; Thu, 12 Jan 2006 09:41:26 -0400 (AST) Received: by xproxy.gmail.com with SMTP id s14so304131wxc for ; Thu, 12 Jan 2006 05:41:30 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=sLb3991V6GBSTEXE5L4V8KYu8YA2nXkySGGD0hmidzEnbclN38KJgfdOsA9neGT8GjKlYJLfvJbdNBkI475GsrIJf1RTf7BcIgucLbOt61Pd32cfJ6OpWUBXeQistYiliixzkLZP+pE/UnVMguIN/x5LcZj/Yu7c2n0Z35O9I2Q= Received: by 10.70.68.5 with SMTP id q5mr2355930wxa; Thu, 12 Jan 2006 05:41:30 -0800 (PST) Received: by 10.70.44.7 with HTTP; Thu, 12 Jan 2006 05:41:30 -0800 (PST) Message-ID: <34608c0c0601120541wd910da3s@mail.gmail.com> Date: Thu, 12 Jan 2006 14:41:30 +0100 From: =?ISO-8859-1?Q?Ott=F3_Havasv=F6lgyi?= To: pgsql-performance@postgresql.org Subject: Re: Throwing unnecessary joins away In-Reply-To: <43C64CFB.9030504@barettadeit.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <34608c0c0601120418n1af567b9n@mail.gmail.com> <43C64CFB.9030504@barettadeit.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.395 required=5 tests=[AWL=0.395] X-Spam-Score: 0.395 X-Spam-Level: X-Archive-Number: 200601/153 X-Sequence-Number: 16631 Hi, As far as I know SQL Server has some similar feature. It does not join if not necessary, more exactly: if the result would be the same if it joined the table. Here is another example: http://www.ianywhere.com/developer/product_manuals/sqlanywhere/0902/en/html= /dbugen9/00000468.htm This would be a fantastic feature. Best Regards, Otto 2006/1/12, Alessandro Baretta : > Ott=F3 Havasv=F6lgyi 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 elimina= ted. > > Or if I do a "table1 left join table2 (table1.referer=3Dtable2.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 > >