Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 574612E006D for ; Mon, 24 Mar 2008 13:30:22 -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 08385-09 for ; Mon, 24 Mar 2008 13:30:13 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id EC0892E003F for ; Mon, 24 Mar 2008 13:30:12 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m2OGUBI7004996; Mon, 24 Mar 2008 12:30:11 -0400 (EDT) To: Dennis Bjorklund cc: PostgreSQL Performance Subject: Re: Turn correlated in subquery into join In-reply-to: <47E7567C.1090804@zigo.dhs.org> References: <47E7567C.1090804@zigo.dhs.org> Comments: In-reply-to Dennis Bjorklund message dated "Mon, 24 Mar 2008 08:21:32 +0100" Date: Mon, 24 Mar 2008 12:30:11 -0400 Message-ID: <4995.1206376211@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/446 X-Sequence-Number: 29400 Dennis Bjorklund writes: > Look like the mysql people found a subquery that postgresql doesn't > handle as good as possible: > http://s.petrunia.net/blog/ > Is there some deeper issue here that I fail to see or is it simply that > it hasn't been implemented but is fairly straigt forward? I don't think it's straightforward: you'd need to do some careful analysis to prove under what conditions such a transformation would be safe. If the answer is "always, it doesn't matter what the correlation condition is" then the actual implementation would probably not be tremendously difficult. If there are restrictions then checking whether the restrictions hold could be interesting ... regards, tom lane