pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Frédérik Bilhaut <frederik.bilhaut@noopsis.fr>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Very strange performance decrease when reusing a PreparedStatement
Date: Wed, 29 Apr 2009 03:21:01 +1200
Message-ID: <49F71EDD.2070200@opencloud.com> (raw)
In-Reply-To: <5C2E1645-73B6-4509-96CD-FA77869516AB@noopsis.fr>
References: <5C2E1645-73B6-4509-96CD-FA77869516AB@noopsis.fr>

Frédérik Bilhaut wrote:
> Hi everybody,
> 
> I am experiencing a *very* strange problem when querying Postgres
> through JDBC using PreparedStatements.
> 
> To say it short, for the same SELECT query :
> 
> - when reusing a single PreparedStatement the average response time per
> query is 60 milliseconds
> 
> - when creating (and closing) a new PreparedStatement each time, the
> average response time drops to only 2 milliseconds !

Try with prepareThreshold=0. Probably, your particular query benefits
from re-planning each time with the particular concrete parameter values
for each execution.

(you can either specify this as a URL parameter, or tweak it on a
per-connection or per-statement basis via methods on
PGConnection/PGStatement)

-O



view thread (26+ messages)  latest in thread

Message-ID: <49F71EDD.2070200@opencloud.com>
Permalink:  ../49F71EDD.2070200@opencloud.com/
Also on:    postgresql.org/message-id/49F71EDD.2070200@opencloud.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: oliver@opencloud.com, frederik.bilhaut@noopsis.fr
  Subject: Re: Very strange performance decrease when reusing a PreparedStatement
  In-Reply-To: <49F71EDD.2070200@opencloud.com>
  References: <5C2E1645-73B6-4509-96CD-FA77869516AB@noopsis.fr> <49F71EDD.2070200@opencloud.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