pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: Craig Ringer <craig@postnewspapers.com.au>
Cc: Dave Crooke <dcrooke@gmail.com>
Cc: pgsql-performance <pgsql-performance@postgresql.org>
Subject: Re: JDBC question for PG 8.3.9
Date: Thu, 15 Apr 2010 06:59:22 -0400
Message-ID: <r2p491f66a51004150359j633411aeid84cf21354094fe9@mail.gmail.com> (raw)
In-Reply-To: <4BC64B64.5070608@postnewspapers.com.au>
References: <y2xca24673e1004141349l531c9710i5ed197a258d6ca8d@mail.gmail.com>
	<4BC64B64.5070608@postnewspapers.com.au>

On Wed, Apr 14, 2010 at 7:10 PM, Craig Ringer
<craig@postnewspapers.com.au> wrote:
> On 15/04/10 04:49, Dave Crooke wrote:
>>
>> Hi foilks
>>
>> I am using PG 8.3 from Java. I am considering a performance tweak which
>> will involve holding about 150 java.sql.PreparedStatment objects open
>> against a single PGSQL connection. Is this safe?
>>
>> I know that MySQL does not support prepared statements /per se/, and so
>> their implementation of PreparedStatement is nothing more than some
>> client-side convenience code that knows how to escape and format
>> constants for you. Is this the case for PG, or does the PG JDBC driver
>> do the real thing?
>
> Pg supports real server-side prepared statements, as does the JDBC driver.
>
> IIRC (and I can't say this with 100% certainty without checking the sources
> or a good look at TFM) the PostgreSQL JDBC driver initially does only a
> client-side prepare. However, if the PreparedStatement is re-used more than
> a certain number of times (five by default?) it switches to server-side
> prepared statements.
>
This is partially true. The driver uses an unnamed prepared statement
on the server.

> This has actually caused a bunch of performance complaints on the jdbc list,
> because the query plan may change at that switch-over point, since with a
> server-side prepared statement Pg no longer has a specific value for each
> parameter and may pick a more generic plan.

This is a limitation of the server, not the driver



view thread (4+ messages)

Message-ID: <r2p491f66a51004150359j633411aeid84cf21354094fe9@mail.gmail.com>
Permalink:  ../r2p491f66a51004150359j633411aeid84cf21354094fe9@mail.gmail.com/
Also on:    postgresql.org/message-id/r2p491f66a51004150359j633411aeid84cf21354094fe9@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-performance@postgresql.org
  Cc: pg@fastcrypt.com, craig@postnewspapers.com.au, dcrooke@gmail.com
  Subject: Re: JDBC question for PG 8.3.9
  In-Reply-To: <r2p491f66a51004150359j633411aeid84cf21354094fe9@mail.gmail.com>
  References: <y2xca24673e1004141349l531c9710i5ed197a258d6ca8d@mail.gmail.com> <4BC64B64.5070608@postnewspapers.com.au> <r2p491f66a51004150359j633411aeid84cf21354094fe9@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