pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Péter Kovács <maxottovonstirlitz@gmail.com>
To: Dave Cramer <pg@fastcrypt.com>
Cc: Frédérik Bilhaut <frederik.bilhaut@noopsis.fr>
Cc: Oliver Jowett <oliver@opencloud.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Very strange performance decrease when reusing a PreparedStatement
Date: Sun, 3 May 2009 18:28:53 +0200
Message-ID: <fdeb32eb0905030928j4e72f1e3vbecb78d0cb74be58@mail.gmail.com> (raw)
In-Reply-To: <491f66a50905030310j5b4cdcd8jbf4f6e757c2ba580@mail.gmail.com>
References: <5C2E1645-73B6-4509-96CD-FA77869516AB@noopsis.fr>
	<49F71EDD.2070200@opencloud.com>
	<02437794-A78D-449C-843F-B823195F9623@noopsis.fr>
	<fdeb32eb0905030122t665113e5nd34e7268d9ab1863@mail.gmail.com>
	<491f66a50905030310j5b4cdcd8jbf4f6e757c2ba580@mail.gmail.com>

On Sun, May 3, 2009 at 12:10 PM, Dave Cramer <pg@fastcrypt.com> wrote:
>
>> It appears that the Postgres "server-prepared statement" cannot handle
>> parameters to the statement. This is really unfortunate, because 99%
>> of real-life applications will want to re-use the same statement
>> (template) with different parameters.
>>
>> The term "server-prepared statement" itself already indicates that
>> there may be something skewed about the "local" semantics of
>> java.sql.PreparedStatements in the Postgres JDBC driver. There is no
>> notion of "client-prepared statement" in the JDBC API, which conceives
>> PreparedStatement instances as mere handles to server side objects.
>> And indeed, Postgres JDBC users have historically been using
>> java.sql.PreparedStatements for its side-effect of preventing SQL
>> injection rather than for the purpose the JDBC API designers had in
>> mind with this class.
>
> I'm not sure where this hypothesis is coming from. Postgresql server
> prepared statements can certainly handle parameters.
>
> What makes you think it can't ?

http://jdbc.postgresql.org/documentation/83/server-prepare.html:

"Server side prepared statements are planned only once by the server.
This avoids the cost of replanning the query every time, but also
means that the planner cannot take advantage of the particular
parameter values used in a particular execution of the query. You
should be cautious about enabling the use of server side prepared
statements globally."

Or is this only the JDBC perspective of things, meaning that the
capability is there at the back-end, just the JDBC driver doesn't take
advantage of it?

Thanks
Peter

>
> Dave
>
>



view thread (26+ messages)  latest in thread

Message-ID: <fdeb32eb0905030928j4e72f1e3vbecb78d0cb74be58@mail.gmail.com>
Permalink:  ../fdeb32eb0905030928j4e72f1e3vbecb78d0cb74be58@mail.gmail.com/
Also on:    postgresql.org/message-id/fdeb32eb0905030928j4e72f1e3vbecb78d0cb74be58@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: maxottovonstirlitz@gmail.com, pg@fastcrypt.com, frederik.bilhaut@noopsis.fr, oliver@opencloud.com
  Subject: Re: Very strange performance decrease when reusing a PreparedStatement
  In-Reply-To: <fdeb32eb0905030928j4e72f1e3vbecb78d0cb74be58@mail.gmail.com>
  References: <5C2E1645-73B6-4509-96CD-FA77869516AB@noopsis.fr> <49F71EDD.2070200@opencloud.com> <02437794-A78D-449C-843F-B823195F9623@noopsis.fr> <fdeb32eb0905030122t665113e5nd34e7268d9ab1863@mail.gmail.com> <491f66a50905030310j5b4cdcd8jbf4f6e757c2ba580@mail.gmail.com> <fdeb32eb0905030928j4e72f1e3vbecb78d0cb74be58@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox