Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id C18799FBE05 for ; Thu, 2 Aug 2007 23:13:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 96166-10 for ; Thu, 2 Aug 2007 23:12:59 -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 F36AE9FBDC8 for ; Thu, 2 Aug 2007 23:13:04 -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 l732D19I028236; Thu, 2 Aug 2007 22:13:01 -0400 (EDT) To: carlos.reimer@opendb.com.br cc: "Alvaro Herrera" , pgsql-performance@postgresql.org Subject: Re: RES: RES: Improving select peformance In-reply-to: References: Comments: In-reply-to "Carlos H. Reimer" message dated "Thu, 02 Aug 2007 22:47:25 -0300" Date: Thu, 02 Aug 2007 22:13:01 -0400 Message-ID: <28235.1186107181@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/17 X-Sequence-Number: 26147 "Carlos H. Reimer" writes: > In this case, I believe the best choice to improve the performance of this > particular SQL statement is adding the 'set join_collapse_limit = 1;' just > before the join statement, correct? That's a mighty blunt instrument. The real problem with your query is the misestimation of the join sizes --- are you sure the table statistics are up to date? Maybe you'd get better estimates with more statistics (ie, increase the stats target for these tables). regards, tom lane