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 F3CEC528FF for ; Thu, 9 Jun 2005 11:55:01 -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 12430-06 for ; Thu, 9 Jun 2005 14:54:59 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id BC874528C7 for ; Thu, 9 Jun 2005 11:54:58 -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 j59EswGV011771; Thu, 9 Jun 2005 10:54:58 -0400 (EDT) To: Jona Cc: Dennis Bjorklund , pgsql-performance@postgresql.org Subject: Re: Query plan changes after pg_dump / pg_restore In-reply-to: <42A7F9D9.8000004@oismail.com> References: <42A7F9D9.8000004@oismail.com> Comments: In-reply-to Jona message dated "Thu, 09 Jun 2005 10:12:09 +0200" Date: Thu, 09 Jun 2005 10:54:58 -0400 Message-ID: <11770.1118328898@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: 200506/213 X-Sequence-Number: 12850 Jona writes: > What worries me is that the plan is different, Given that the estimated costs are close to the same, this is probably just the result of small differences in the ANALYZE statistics leading to small differences in cost estimates and thus choice of different plans. I'll bet if you re-ANALYZE a few times on the source database you'll see it flipping between plan choices too. This is normal because ANALYZE takes a random sample of rows rather than being exhaustive. So the interesting question is not "why are the plan choices different" it is "how do I get the cost estimates closer to reality". That's the only way in the long run to ensure the planner makes the right choice. Increasing the statistics targets or fooling with planner cost parameters are the basic tools you have available here. regards, tom lane