X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D295E476053 for ; Tue, 4 Mar 2003 05:54:54 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 61992-07 for ; Tue, 4 Mar 2003 05:54:50 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 51D9D476060 for ; Tue, 4 Mar 2003 05:54:50 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 3F21343A918; Tue, 4 Mar 2003 05:54:50 -0500 (EST) From: Oleg Samoylov X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Insert multiple Rows Date: Tue, 04 Mar 2003 13:54:40 +0300 Organization: MIPT Telecom Lines: 32 Message-ID: References: <6f079210.0303030838.21f184af@posting.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: ru, en In-Reply-To: <6f079210.0303030838.21f184af@posting.google.com> To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/111 X-Sequence-Number: 12151 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 = 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. -- Olleg Samoylov