pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: Oleg Samoylov <olleg@telecom.mipt.ru>
To: pgsql-sql@postgresql.org
Subject: Re: Insert multiple Rows
Date: Tue, 4 Mar 2003 11:19:30 +0000
Message-ID: <200303041119.30866.gary.stainburn@ringways.co.uk> (raw)
In-Reply-To: <b420lg$1um4$1@news.hub.org>
References: <6f079210.0303030838.21f184af@posting.google.com>
	<b420lg$1um4$1@news.hub.org>

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 = 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 things 
up - maybe by defering index updates?
-- 
Gary Stainburn
 
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     




view thread (7+ messages)  latest in thread

Message-ID: <200303041119.30866.gary.stainburn@ringways.co.uk>
Permalink:  ../200303041119.30866.gary.stainburn@ringways.co.uk/
Also on:    postgresql.org/message-id/200303041119.30866.gary.stainburn@ringways.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gary.stainburn@ringways.co.uk, olleg@telecom.mipt.ru
  Subject: Re: Insert multiple Rows
  In-Reply-To: <200303041119.30866.gary.stainburn@ringways.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox