Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 9CE9B9FBA8E for ; Fri, 23 Mar 2007 19:18:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 00866-03 for ; Fri, 23 Mar 2007 19:18:46 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.171]) by postgresql.org (Postfix) with ESMTP id 3424F9FB994 for ; Fri, 23 Mar 2007 19:18:51 -0300 (ADT) Received: from mac.com (smtpin03-en2 [10.13.10.148]) by smtpout.mac.com (Xserve/smtpout01/MantshX 4.0) with ESMTP id l2NMIle0015386; Fri, 23 Mar 2007 15:18:47 -0700 (PDT) Received: from [192.168.124.109] (207-172-69-98.c3-0.wth-ubr2.sbo-wth.ma.static.cable.rcn.com [207.172.69.98]) (authenticated bits=0) by mac.com (Xserve/smtpin03/MantshX 4.0) with ESMTP id l2NMIiQU010678 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 23 Mar 2007 15:18:46 -0700 (PDT) In-Reply-To: <25685.1174688032@sss.pgh.pa.us> References: <5335C295-4D3E-4A1B-A270-6B822377DD25@mac.com> <25685.1174688032@sss.pgh.pa.us> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <797C9FCF-8C8C-4813-8979-68DF7B70FFF8@mac.com> Cc: pgsql-performance@postgresql.org Content-Transfer-Encoding: 7bit From: "Noah M. Daniels" Subject: Re: Strange left outer join performance issue Date: Fri, 23 Mar 2007 18:18:34 -0400 To: Tom Lane X-Mailer: Apple Mail (2.752.3) X-Brightmail-Tracker: AAAAAA== X-Brightmail-scanned: yes X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/379 X-Sequence-Number: 23784 Tom, You're right; this is postgres 8.0.8. Perhaps upgrading will solve this issue. Is there any way to get this query to perform better in postgres 8.0.8? thanks! On Mar 23, 2007, at 6:13 PM, Tom Lane wrote: > "Noah M. Daniels" writes: >> I have two queries that are very similar, that run on the same table >> with slightly different conditions. However, despite a similar number >> of rows returned, the query planner is insisting on a different >> ordering and different join algorithm, causing a huge performance >> hit. I'm not sure why the planner is doing the merge join the way it >> is in the slow case, rather than following a similar plan to the fast >> case. > > It likes the merge join because it predicts (apparently correctly) > that > only about 1/14th of the table will need to be scanned. This'd be an > artifact of the relative ranges of supplier ids in the two tables. > > What PG version is this? 8.2 understands about repeated indexscans > being cheaper than standalone ones, but I get the impression from the > explain estimates that you may be using something older that's > overestimating the cost of the nestloop way. > > regards, tom lane > > ---------------------------(end of > broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings