Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id BE6029F9F82 for ; Wed, 31 Oct 2007 19:57:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 58850-05 for ; Wed, 31 Oct 2007 19:56:42 -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 402D09FA5CD for ; Wed, 31 Oct 2007 19:05:19 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l9VM5GkF021629; Wed, 31 Oct 2007 18:05:16 -0400 (EDT) To: Sami Dalouche cc: pgsql-performance Subject: Re: [Fwd: Re: Outer joins and Seq scans] In-reply-to: <1193865739.23774.2.camel@samlaptop> References: <1193865739.23774.2.camel@samlaptop> Comments: In-reply-to Sami Dalouche message dated "Wed, 31 Oct 2007 22:22:19 +0100" Date: Wed, 31 Oct 2007 18:05:16 -0400 Message-ID: <21628.1193868316@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/391 X-Sequence-Number: 27413 Sami Dalouche writes: > -- For some reason, my message doesn't seem to go through the mailing > list, so I am trying without any attachment Please don't do that, at least not that way. These explain outputs have been line-wrapped to the point of utter unreadability. The main problem looks to me that you're trying to do a 25-way join. You'll want to increase join_collapse_limit and maybe fool with the geqo parameters. I fear you won't get a plan in a sane amount of time if you try to do the full query as a single exhaustive search. You can either raise join_collapse_limit all the way and trust geqo to find a decent plan repeatably (not a real safe assumption unfortunately) or raise both join_collapse_limit and geqo_threshold to some intermediate level and hope that a slightly wider partial plan search will find the plan you need. It's also possible that you're just stuck and the outer join is inherently harder to execute. I didn't study the query closely enough to see if it's joining to any left join right-hand-sides, or anything else that would forbid picking a nice join order. regards, tom lane