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

Re: Very strange performance decrease when reusing a PreparedStatement

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Frédérik Bilhaut <frederik(dot)bilhaut(at)noopsis(dot)fr>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Very strange performance decrease when reusing a PreparedStatement
Date: 2009-04-28 15:21:01
Message-ID: 49F71EDD.2070200@opencloud.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
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

In response to

Responses

pgsql-jdbc by date

Next:From: Oliver HitzDate: 2009-04-28 19:55:40
Subject: Re: Thread hangs in VisibleBufferedInputStream.readMore
Previous:From: Oliver HitzDate: 2009-04-28 11:40:48
Subject: Re: Thread hangs in VisibleBufferedInputStream.readMore

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