Re: Very strange performance decrease when reusing a PreparedStatement - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Very strange performance decrease when reusing a PreparedStatement
Date
Msg-id 49F71EDD.2070200@opencloud.com
Whole thread Raw
In response to Very strange performance decrease when reusing a PreparedStatement  (Frédérik Bilhaut <frederik.bilhaut@noopsis.fr>)
Responses Re: Very strange performance decrease when reusing a PreparedStatement
List 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

pgsql-jdbc by date:

Previous
From: Frédérik Bilhaut
Date:
Subject: Very strange performance decrease when reusing a PreparedStatement
Next
From: Oliver Hitz
Date:
Subject: Re: Thread hangs in VisibleBufferedInputStream.readMore