Skip site navigation (1) Skip section navigation (2)

Re: Bind message

From: Mark Lewis <mark(dot)lewis(at)mir3(dot)com>
To: Guy Rouillier <guyr(at)masergy(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Bind message
Date: 2006-09-25 19:23:18
Message-ID: 1159212198.9657.1713.camel@archimedes (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
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

-- Mark

In response to

pgsql-jdbc by date

Next:From: Markus SchaberDate: 2006-09-25 21:14:24
Subject: Re: Bind message
Previous:From: Kris JurkaDate: 2006-09-25 19:21:09
Subject: Re: Bind message

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group