X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D5D41D1D25D for ; Thu, 19 Feb 2004 16:33:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 23436-05 for ; Thu, 19 Feb 2004 12:32:56 -0400 (AST) Received: from mail2.itxmarket.com (fw.itxmarket.com [213.11.40.109]) by svr1.postgresql.org (Postfix) with ESMTP id 62D59D1E141 for ; Thu, 19 Feb 2004 12:32:40 -0400 (AST) Received: from freebsdcluster.net (mich2.itxmarket.com [192.168.2.26]) by mail2.itxmarket.com (Postfix) with ESMTP id 6AD8337CF1 for ; Thu, 19 Feb 2004 17:32:38 +0100 (CET) Received: by freebsdcluster.net (Postfix, from userid 1001) id 5D0AB2282B; Thu, 19 Feb 2004 17:32:38 +0100 (CET) Date: Thu, 19 Feb 2004 17:32:38 +0100 From: "Michael L. Hostbaek" To: pgsql-sql@postgresql.org Subject: postgresql multiple insert slow Message-ID: <20040219163238.GD10913@mich2.itxmarket.com> Mail-Followup-To: "Michael L. Hostbaek" , pgsql-sql@postgresql.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: FreeBSD 5.2-RC i386 X-PGP-Key: http://www.freebsdcluster.org/~mich/ User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/326 X-Sequence-Number: 17016 Hello, 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); $sth->finish; } } [...] 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. /mich -- Best Regards, Michael L. Hostbaek */ PGP-key available upon request /*