Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id E292363225A for ; Mon, 22 Feb 2010 17:21:13 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 31290-07 for ; Mon, 22 Feb 2010 21:20:59 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 13183632175 for ; Mon, 22 Feb 2010 17:21:02 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o1MLKwDn001802; Mon, 22 Feb 2010 16:20:58 -0500 (EST) To: Joel Jacobson cc: "Pierre C" , pgsql-performance@postgresql.org Subject: Re: plpgsql plan cache In-reply-to: <8AD3F6B6-BCCF-46E1-B255-9EB8E761653B@gluefinance.com> References: <38E2265E-B38E-4EBD-BB87-23B46EF4FD1C@gluefinance.com> <8AD3F6B6-BCCF-46E1-B255-9EB8E761653B@gluefinance.com> Comments: In-reply-to Joel Jacobson message dated "Mon, 22 Feb 2010 20:58:10 +0100" Date: Mon, 22 Feb 2010 16:20:58 -0500 Message-ID: <1801.1266873658@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.466 tagged_above=-10 required=5 tests=AWL=0.133, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/303 X-Sequence-Number: 37724 Joel Jacobson writes: > Hm, it is strange the query planner is using two different strategies > for the same query? They're not the same query. One plan is generic for any value of the parameters, the other is chosen for specific values of those parameters. In particular, the unparameterized query depends very strongly on the knowledge that not many rows will meet the RecordDate range constraint. If you picked dates that were further apart you'd probably get something that looked more like the other plan. regards, tom lane