Skip site navigation (1) Skip section navigation (2)

postgresql multiple insert slow

From: "Michael L(dot) Hostbaek" <mich(at)freebsdcluster(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: postgresql multiple insert slow
Date: 2004-02-19 16:32:38
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql

I've got a table in an oracle database with approx. 100000 records, that
I'd like to put into a table in a postgresql database. (This should be
done a couple of times per week)

I have written a short perl script, on a server that has remote access
to both the oracle database as well as the postgresql database. I am
running postgresql 7.4.1 on FreeBSD.

My perl script looks something like this:

my $sth2 = $cnx2->prepare('SELECT * FROM oracle_table');
my $res2 = $sth2->execute();

while(my($field2,$field5,$field6) = ($sth2->fetchrow_array)) {
	if(defined($field2)) {
		my $sth = $cnx->prepare('INSERT INTO
the_pg_table(field1, field2) VALUES(?,?)');
		my $result = $sth->execute($field2,$field5);


I runs fine - and I get no errors - but it takes almost 25 minutes to
complete.. I tried running the script while just grabbing the rows from
the oracle database and writing to a text file - and then it only takes
a couple of minutes .. So it must be the INSERT command that chokes - is
there a better way to do it ? 

Any advise much appreciated.


Best Regards,
	Michael L. Hostbaek 

	*/ PGP-key available upon request /*


pgsql-sql by date

Next:From: scott.marloweDate: 2004-02-19 16:38:09
Subject: Re: Distributed Transactions
Previous:From: Stephan SzaboDate: 2004-02-19 16:20:12
Subject: Re: Compiling pl/pgsql functions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group