X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9DB2F537BC for ; Sat, 23 Apr 2005 21:10:09 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 31251-04 for ; Sun, 24 Apr 2005 00:10:04 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id B9AAB537B0 for ; Sat, 23 Apr 2005 21:10:03 -0300 (ADT) 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 j3O0A5ff024113; Sat, 23 Apr 2005 20:10:05 -0400 (EDT) To: John A Meinel Cc: "Shoaib Burq (VPAC)" , Russell Smith , Jeff , pgsql-performance@postgresql.org Subject: Re: two queries and dual cpu (perplexed) In-reply-to: <4267C34D.9010705@arbash-meinel.com> References: <4267C34D.9010705@arbash-meinel.com> Comments: In-reply-to John A Meinel message dated "Thu, 21 Apr 2005 10:14:21 -0500" Date: Sat, 23 Apr 2005 20:10:05 -0400 Message-ID: <24112.1114301405@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/658 X-Sequence-Number: 12055 John A Meinel writes: > Actually, you probably don't want enable_seqscan=off, you should try: > SET enable_nestloop TO off. > The problem is that it is estimating there will only be 44 rows, but in > reality there are 13M rows. It almost definitely should be doing a > seqscan with a sort and merge join. Not nestloops anyway. > I don't understand how postgres could get the number of rows that wrong. No stats, or out-of-date stats is the most likely bet. > I can't figure out exactly what is where from the formatting, but the query that seems misestimated is: > -> Index Scan using "IX_ClimateId" on "ClimateChangeModel40" (cost=0.00..1063711.75 rows=265528 width=20) (actual time=28.311..17212.703 rows=13276368 loops=1) > Index Cond: ("outer"."ClimateId" = "ClimateChangeModel40"."ClimateId") Yeah, that's what jumped out at me too. It's not the full explanation for the join number being so far off, but this one at least you have a chance to fix by updating the stats on ClimateChangeModel40. regards, tom lane