Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: really quick multiple inserts can use COPY?



On 12/11/06, Andreas Kretschmer <akretschmer(at)spamfence(dot)net> wrote:
Jens Schipkowski <jens(dot)schipkowski(at)apus(dot)co(dot)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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group