Re: setPrepareThreshold

Поиск
Список
Период
Сортировка
От Sehrope Sarkuni
Тема Re: setPrepareThreshold
Дата
Msg-id CAH7T-aqtP0BFAuWSCQjdR9-hdz8NFGKK=vLsOLADxO11HZDrgw@mail.gmail.com
обсуждение исходный текст
Ответ на setPrepareThreshold  (Robert DiFalco <robert.difalco@gmail.com>)
Ответы Re: setPrepareThreshold  (Robert DiFalco <robert.difalco@gmail.com>)
Список pgsql-jdbc
On Fri, Jan 17, 2014 at 10:31 AM, Robert DiFalco
<robert.difalco@gmail.com> wrote:
> I was wondering why this setting exists and why it is by default disabled?

This setting is the number of times a PreparedStatement needs to be
reused before the driver instructs the PostgreSQL server to create a
server side prepared statement for it. Server side prepared statements
have cached executions plans so in theory they should run a bit
faster. The down side is that they take up resources (memory to cache
the plan) and since the plan is cached, it won't change if you change
based up on the passed in parameters.

The default isn't disabled, it's "5". That means that if you execute
the same PreparedStatement 5 times it will be converted to server side
prepared statement and subsequent executions will use the server side
one.

> Is there some danger associated with it or some reason I would NOT want it
> to be set?

If you set it very low and you have a lot of different SQL statements
that aren't actually being reused, then you will have a lot of
prepared statements on the server side taking up needless resources.
The default of "5" should be fine for most purposes.

Check out these links for more details:

http://jdbc.postgresql.org/documentation/81/server-prepare.html
http://stackoverflow.com/questions/8104595/why-is-the-postgresql-jdbc-prepared-statement-threshold-defaulted-to-5

Regards,
-- Sehrope Sarkuni


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: setPrepareThreshold
Следующее
От: Jeremy Whiting
Дата:
Сообщение: Re: Performance improvement proposal. Removal of toLowerCase calls.