pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: imad <immaad@gmail.com>
To: Andreas Kretschmer <akretschmer@spamfence.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: really quick multiple inserts can use COPY?
Date: Tue, 12 Dec 2006 00:22:19 +0500
Message-ID: <1f30b80c0612111122i347e5f31k39a8193db2d4cd10@mail.gmail.com> (raw)
In-Reply-To: <20061211165731.GA11970@KanotixBox>
References: <op.tkekypo381rjf6@xjens.apus.local>
	<20061211165731.GA11970@KanotixBox>

On 12/11/06, Andreas Kretschmer <akretschmer@spamfence.net> wrote:
> Jens Schipkowski <jens.schipkowski@apus.co.at> schrieb:
>
> > 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.
>
> Can you change this from INSERT-Statements to COPY? Copy is *much*
> faster than INSERT.
>
> If no, do you using all INSERTs in one transaction? I believe, a 'BEGIN'
> and a 'COMMIT' around all INSERTs may increase the speed.


Performance increment can also be gained by disabling constraints in the
transaction. These disabled constraints are invoked at the end of the
transaction according to the SQL standard, so no worries about data
consistency.

Hmmm... PG currently supports disabling foreign constraints only. But that
can still be significant.

--Imad
www.EnterpriseDB.com



view thread (8+ messages)  latest in thread

Message-ID: <1f30b80c0612111122i347e5f31k39a8193db2d4cd10@mail.gmail.com>
Permalink:  ../1f30b80c0612111122i347e5f31k39a8193db2d4cd10@mail.gmail.com/
Also on:    postgresql.org/message-id/1f30b80c0612111122i347e5f31k39a8193db2d4cd10@mail.gmail.com

 · 

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-performance@postgresql.org
  Cc: immaad@gmail.com, akretschmer@spamfence.net
  Subject: Re: really quick multiple inserts can use COPY?
  In-Reply-To: <1f30b80c0612111122i347e5f31k39a8193db2d4cd10@mail.gmail.com>

* 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