raising the default prepareTheshold - Mailing list pgsql-jdbc

From Oliver Jowett
Subject raising the default prepareTheshold
Date
Msg-id 414CA8A0.7070707@opencloud.com
Whole thread Raw
Responses Re: raising the default prepareTheshold  (Kris Jurka <books@ejurka.com>)
Re: raising the default prepareTheshold  (Markus Schaber <schabios@logi-track.com>)
List pgsql-jdbc
I'd like to raise the default prepareThreshold to some non-zero value,
perhaps 5 or so. This means that PreparedStatements that are used more
than 5 times will allocate and use a named backend statement.

Usually, using a named statement is a performance win as it avoids
reparsing and replanning the query on each execution; I've seen
measurable improvement (at least 15%, from memory) on heavily-reused
simple queries where the parse/plan cost is a noticable fraction of
total execution time.

However, with a 8.0 backend, if the planner benefits from knowing the
particular parameter values in use for a particular query, then using an
unnamed statement may be faster due to using an improved plan. Under 7.4
there will be no difference; both named and unnamed statements will use
the generic plan.

So using named statements always by default (default prepareThreshold =
1) probably isn't a good idea. Using a default prepareThreshold > 1
seems like a reasonable compromise.

What does everyone think?

-O

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: "Idle in Transaction" revisited.
Next
From: Jeffrey Tenny
Date:
Subject: Re: "Idle in Transaction" revisited.