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

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to