Re: Prepared Statements and Pooling

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Prepared Statements and Pooling
Дата
Msg-id CAF-3MvP3mWOxe2LbSJEw8j4cTtX8gVPkFkrAojyxndCKeXu4sw@mail.gmail.com
обсуждение исходный текст
Ответ на Prepared Statements and Pooling  (Mister Junk <junkmail3568540@gmail.com>)
Список pgsql-general
On 11 August 2015 at 06:44, Mister Junk <junkmail3568540@gmail.com> wrote:
> I'm using prepared statements to prevent SQL injection, but I have done some
> reading and it seems like using Prepared statements COULD improve
> performance.  I understand the concept, but I do not know how to implement
> this.

They could, they could also reduce performance.

Prepared statements store and reuse an earlier generated query plan
for a query, so that's the time you safe.

However, because the query planner can't make use of the actual query
parameter values (they are yet unknown at that point), it can only
generate a general query plan.

If your data is equally distributed for your query parameters, that
won't matter much, but if some values are far more common than others,
that can actually hurt performance.

In case of a normal statement, the query planner has enough
information to decide which plan would be more efficient. With a
prepared statement it has not.


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

Предыдущее
От: Andomar
Дата:
Сообщение: Re: Prepared Statements and Pooling
Следующее
От: Michael H
Дата:
Сообщение: Postgresql-9.1 CentOS7 effective_cache_size issue