Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id EFAD89F9F75 for ; Mon, 11 Dec 2006 13:13:34 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 65796-03 for ; Mon, 11 Dec 2006 13:13:11 -0400 (AST) X-Greylist: delayed 00:18:49.702874 by SQLgrey-1.7.4 Received: from mail.mnc.ch (62-2-77-205.static.cablecom.ch [62.2.77.205]) by postgresql.org (Postfix) with ESMTP id 119D29F9FDA for ; Mon, 11 Dec 2006 13:13:11 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mail.mnc.ch (Postfix) with ESMTP id 27AF2A8313; Mon, 11 Dec 2006 17:54:19 +0100 (CET) Received: from mail.mnc.ch ([127.0.0.1]) by localhost (mail.test.lan [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id 01252-01; Mon, 11 Dec 2006 17:54:16 +0100 (CET) Received: from meuh.mnc.lan (62-2-77-204.static.cablecom.ch [62.2.77.204]) by mail.mnc.ch (Postfix) with ESMTP id C27B8A82FD; Mon, 11 Dec 2006 17:54:16 +0100 (CET) Received: by meuh.mnc.lan (Postfix, from userid 1000) id E14B31836D7; Mon, 11 Dec 2006 17:53:52 +0100 (CET) To: "Jens Schipkowski" Cc: pgsql-performance@postgresql.org Subject: Re: really quick multiple inserts can use COPY? References: X-Hashcash: 1:20:061211:jens.schipkowski@apus.co.at::xJuoRnal49cLxI5m:00000000000000000000000000000000000g/3 X-Hashcash: 1:20:061211:pgsql-performance@postgresql.org::dIjFbfsBdhkI/Mvn:0000000000000000000000000000014ci From: Guillaume Cottenceau Date: 11 Dec 2006 17:53:52 +0100 In-Reply-To: Message-ID: <87vekiqspr.fsf@meuh.mnc.lan> Lines: 25 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: amavisd-new at mnc.ch X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/246 X-Sequence-Number: 22302 "Jens Schipkowski" writes: > Hello! > > In our JAVA application we do multiple inserts to a table by data from > a Hash Map. Due to poor database access implemention - done by > another company (we got the job to enhance the software) - we cannot > use prepared statements. (We are not allowed to change code at > database access!) > First, we tried to fire one INSERT statement per record to insert. > This costs 3 ms per row which is to slow because normally we insert > 10.000 records which results in 30.000 ms just for inserts. > > for(){ > sql = "INSERT INTO tblfoo(foo,bar) VALUES("+it.next()+","+CONST.BAR+");"; > } You should try to wrap that into a single transaction. PostgreSQL waits for I/O write completion for each INSERT as it's implicitely in its own transaction. Maybe the added performance would be satisfactory for you. -- Guillaume Cottenceau Create your personal SMS or WAP Service - visit http://mobilefriends.ch/