Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 1A6352E0049 for ; Tue, 4 Dec 2007 12:33:05 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 15865-08 for ; Tue, 4 Dec 2007 12:32:48 -0400 (AST) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 31FE62E004D for ; Tue, 4 Dec 2007 12:33:00 -0400 (AST) 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 lB4GWwfq029383; Tue, 4 Dec 2007 11:32:58 -0500 (EST) To: Pallav Kalva cc: pgsql-performance@postgresql.org Subject: Re: Optimizer Not using the Right plan In-reply-to: <47557AED.8050005@livedatagroup.com> References: <47557AED.8050005@livedatagroup.com> Comments: In-reply-to Pallav Kalva message dated "Tue, 04 Dec 2007 11:06:05 -0500" Date: Tue, 04 Dec 2007 11:32:58 -0500 Message-ID: <29382.1196785978@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/50 X-Sequence-Number: 27866 Pallav Kalva writes: > why does it have different plans for different values Because the values occur different numbers of times (or so it thinks anyway). If the rowcount estimates are far from reality, perhaps increasing the statistics target would help. However, since you only showed EXPLAIN and not EXPLAIN ANALYZE output, no one can really tell whether the optimizer did anything wrong here. regards, tom lane