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 2D93B9DCC0D for ; Wed, 22 Feb 2006 11:04:12 -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 25644-10 for ; Wed, 22 Feb 2006 11:04:16 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 98BA49DCC19 for ; Wed, 22 Feb 2006 11:04:09 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k1MF4502011674; Wed, 22 Feb 2006 10:04:05 -0500 (EST) To: Richard Huxton cc: George Woodring , pgsql-performance@postgresql.org Subject: Re: Help with nested loop left join performance In-reply-to: <43FC30FC.3080800@archonet.com> References: <1B1B254441DB31448BD34C5BD73B0B8B28FBF6@PHOENIX.istructure.com> <43FC30FC.3080800@archonet.com> Comments: In-reply-to Richard Huxton message dated "Wed, 22 Feb 2006 09:38:04 +0000" Date: Wed, 22 Feb 2006 10:04:05 -0500 Message-ID: <11673.1140620645@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.11 required=5 tests=[AWL=0.110] X-Spam-Score: 0.11 X-Spam-Level: X-Archive-Number: 200602/341 X-Sequence-Number: 17327 Richard Huxton writes: > George Woodring wrote: >> FROM >> settop_billing >> LEFT OUTER JOIN >> (dhct JOIN dhct_davic USING(mac)) >> USING >> (mac) >> WHERE >> region='GTown1E' AND node='1E012' > With 7.4 I seem to remember that explicit JOINs force the evaluation > order, but I'm not if even later versions will rewrite your query. It's > too early in the morning for me to figure out if it's safe in all cases. CVS HEAD can re-order left joins in common cases, but no existing release will touch the ordering of outer joins at all. It's impossible to tell here which tables the WHERE-clause restrictions actually bear on, so there's no way to say whether a different join order would help. My guess though is that George may be stuck --- in general you can't move a join into or out of the right side of a left join without changing the answers. regards, tom lane