Re: psql vs perl prepared inserts

From: Dawid Kuroczko <qnex42(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: psql vs perl prepared inserts
Date: 2005-04-13 08:12:50
Message-ID: 758d5e7f0504130112186213fb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 4/12/05, Matt Van Mater <matt(dot)vanmater(at)gmail(dot)com> wrote:
> I've been experimenting with loading a large amount of data into a
> fairly simple database using both psql and perl prepared statements.
> Unfortunately I'm seeing no appreciable differences between the two
> methods, where I was under the impression that prepared statements
> should be much faster (in my case, they are slightly slower).

I've been playing with similar issue and in my case the best solution
for bulk insert was using perl to format data in form suitable for COPY
command.

I believe there may be problems if you have RULEs on table you want
to copy data into (IIRC such RULEs will be ignored).

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. (And there is a quite a chance that your psql will outperform
perl using this syntax).

Regards,
Dawid

PS: I have not tested these statements, yet they should be ok; make
sure the argument list (int,inet,boolean...) is correct for your data.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sean Davis 2005-04-13 10:11:32 Re: psql vs perl prepared inserts
Previous Message Clifton Zama 2005-04-13 08:01:21 Connection closing