Re: psql vs perl prepared inserts

From: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>
To: Matt Van Mater <matt(dot)vanmater(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: psql vs perl prepared inserts
Date: 2005-04-13 15:43:43
Message-ID: 2ec71503fd0f0e951ef539243581307c@mail.nih.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Apr 13, 2005, at 9:57 AM, Matt Van Mater wrote:

> Thanks to all who replied. Thanks for the tip on that last thread
> Tom, I don't know how I missed it. I have a hunch that it's not
> applicable to me at this time because I'm running a year and a half
> old software (included in OpenBSD 3.4), but I will have to check which
> version of DBD::Pg was installed.
>
>> 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.
>
> I was thinking something along the same lines, and was considering
> using the COPY statement as my next step, but as someone mentioned
> then I have to load it into a temporary database and then do some more
> internal magic to preserve referential integrity, unique contraints,
> etc. For that reason I was hoping to keep it in perl, and it's always
> nice to keep everything in a single neat portable package.

You can use pl/perl stored functions to do exactly what you do in perl
on the client side, but it happens much faster since the data is
already on the server. Then, your neat little portable package IS the
database.

Sean

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ying Lu 2005-04-13 15:49:56 About ERROR: could not convert UTF-8 character 0x00e9 to ISO8859-1
Previous Message Eric D. Nielsen 2005-04-13 15:41:41 Re: PostGreSQL (7.3?) recovery, Mac OS X (10.3.8)