X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 309AA475FC4 for ; Tue, 4 Mar 2003 06:22:48 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 68187-05 for ; Tue, 4 Mar 2003 06:22:46 -0500 (EST) Received: from stan.ringways.co.uk (hub.ringways.co.uk [213.38.87.130]) by postgresql.org (Postfix) with ESMTP id 60931475D3B for ; Tue, 4 Mar 2003 06:22:46 -0500 (EST) Received: from gary.ringways.co.uk ([10.1.1.2]) by stan.ringways.co.uk with esmtp (Exim 3.22 #1) id 18qATY-0002fC-00; Tue, 04 Mar 2003 11:20:48 +0000 Content-Type: text/plain; charset="iso-8859-1" From: Gary Stainburn Organization: Ringways Garages Ltd To: Oleg Samoylov , pgsql-sql@postgresql.org Subject: Re: Insert multiple Rows Date: Tue, 4 Mar 2003 11:19:30 +0000 User-Agent: KMail/1.4.3 References: <6f079210.0303030838.21f184af@posting.google.com> In-Reply-To: MIME-Version: 1.0 Message-Id: <200303041119.30866.gary.stainburn@ringways.co.uk> Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/113 X-Sequence-Number: 12153 On Tuesday 04 Mar 2003 10:54 am, Oleg Samoylov wrote: > Hi, > > Saint X wrote: > > Hi, I have a program that need to send a Postgresql database a lot of > > rows, i'm doing it using FOR an INSERT, something like this > > for i =3D 0 to 1000 > > { > > insert into table(item1) VALUES (i); > > } > > > > And so on, as you can imagine these consume a lot of resources and > > move so slowly, that's why I'm looking for a command to send more than > > one row at the time, something like > > > > insert into table (item1) values ('1' / '2' / '3' / '4' ... / '1000'); > > You can do instead: > > insert into table (item1) values ('1'); > insert into table (item1) values ('2'); > .... > insert into table (item1) values ('1000'); > > As single query. > > But better use COPY command or prepared statment. > > Inserts slow commonly due to indexis and foreing keys. If you use a 'prepared' insert within a transaction, would that speed thing= s=20 up - maybe by defering index updates? --=20 Gary Stainburn =20 This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000=20= =20=20=20=20