Re: psql vs perl prepared inserts

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Re: psql vs perl prepared inserts
Дата
Msg-id 425D0AD9.80401@samurai.com
обсуждение исходный текст
Ответ на Re: psql vs perl prepared inserts  (Dawid Kuroczko <qnex42@gmail.com>)
Ответы Re: psql vs perl prepared inserts
Re: psql vs perl prepared inserts
Re: psql vs perl prepared inserts
Список pgsql-general
Dawid Kuroczko wrote:
> For a test you might want to try also this approach (both from perl and
> from psql):
>
> $dbh->do('PREPARE sth_tim (int,inet,boolean,timestamptz) AS INSERT
> INTO timestamps VALUES ($1,$2,$3,$4)');
> $sth_tim  = $dbh->prepare("EXECUTE sth_tim(?,?,?,?)");
>
> ...and later execute it.  (and likewise with psql).  If you'll see gain in speed
> with perl it means your DBD::Pg wasn't using server side prepared
> statements.

The intent of prepared statements is to reduce the overhead of running
the parser, rewriter and planner multiple times for a statement that is
executed multiple times. For an INSERT query without any sub-selects
that is not rewritten by any rules, the cost to parse, rewrite and plan
the statement is trivial. So I wouldn't expect prepared statements to be
a big win -- you would gain a lot more from batching multiple inserts
into a single transaction, and more still from using COPY.

-Neil

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

Предыдущее
От: Robert Treat
Дата:
Сообщение: Re: What are the consequences of a bad database design (never seen that before !)
Следующее
От: Matt Van Mater
Дата:
Сообщение: Re: psql vs perl prepared inserts