Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 2BC819FB1F5 for ; Mon, 25 Sep 2006 16:23:26 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 39495-08 for ; Mon, 25 Sep 2006 16:23:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) by postgresql.org (Postfix) with ESMTP id 2A3999FB1CC for ; Mon, 25 Sep 2006 16:23:19 -0300 (ADT) Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP with MS-WebStorage 6.0.6249 Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; 25 Sep 2006 12:23:18 -0700 Subject: Re: Bind message From: Mark Lewis To: Guy Rouillier Cc: pgsql-jdbc@postgresql.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: MIR3, Inc. Date: Mon, 25 Sep 2006 12:23:18 -0700 Message-Id: <1159212198.9657.1713.camel@archimedes> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-27) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.178 tagged_above=0 required=5 tests=AWL, UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200609/104 X-Sequence-Number: 15822 On Mon, 2006-09-25 at 14:00 -0500, Guy Rouillier wrote: > Dave Cramer wrote: > > Hi, > > > > > > The default is not to re-use statements, you have add > > prepareThreshold=n to the url where n is greater than 0. What this > > means is that after n times of use the prepared statement will be > > re-used.. > > That's peculiar. The whole point of prepared statements is to obtain > the optimization of statement reuse. If PostgreSQL is going to prevent > that, I'd expect the prevention to be the exception rather than the > rule. That is, programmers should reasonably expect that the default > behavior is statement reuse. Well, yes and no. Yes, the original intent of PreparedStatements was to increase efficiency by reuse. But in practice, since there's no easy way of specifying parameters programatically except by using the PreparedStatement interface, most programs which construct one-time-only SQL on the fly also use PreparedStatements. There can be a significant benefit to NOT using generic prepared statements in the one-shot (or few-shot) case; the planner can see real parameter values instead of placeholders, and can thus make smarter plan decisions. -- Mark