Re: pooled prepared statements

From: Kris Jurka <books(at)ejurka(dot)com>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: Thomas Finneid <tfinneid(at)fcon(dot)no>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: pooled prepared statements
Date: 2009-05-14 18:58:26
Message-ID: Pine.BSO.4.64.0905141451530.12930@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Wed, 13 May 2009, Oliver Jowett wrote:

> Thomas Finneid wrote:
>
>> When a PreparedStatment is created by a pooled connection, as far as I
>> understand if, that creation happens on the server side, and a
>> reference, of sorts, is returned to the client jdbc.
>
> More or less, yes. (Assuming you're reusing the statement, not just
> using it once and discarding it).
>

It really depends on the driver and connection pool that you are using.
The idea of having a PreparedStatement cache (that doesn't require
retaining a reference to the PreparedStatement) has been suggested for the
driver, but rejected. A connection pool which proxies the real connection
can provide this functionality instead. The pooler provided with the
postgresql driver does not do this, but for example DBCP can.

So as long as your pool or driver are reasonably smart, don't overthink
this and let them handle it for you.

Kris Jurka

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Rees 2009-05-14 21:28:03 Re: v604 in Maven
Previous Message Kris Jurka 2009-05-14 18:47:54 Re: COPY support: plan and progress