Fast Insert and Update (through COPY)

From: Yan Cheng CHEOK <yccheok(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Fast Insert and Update (through COPY)
Date: 2010-12-15 15:17:30
Message-ID: 738974.76908.qm@web65715.mail.ac4.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Previously, I am inserting a bulk of data by using the following way.

for each item
update item into table
if row count is 0
insert items into table

I realize I am suffering performance problem.

Later, I realize it is much fast by using

COPY

I am very happy with the speed.

Later, I realize that COPY doesn't work well, if I already have a row with same unique key. What I did is

# Try to remove old rows first
delete row where <condition>
# And perform really fast insertion
COPY

I was wondering, is this a common technique being use for fast bulk data insertion? Is there other techniques.

Thanks and Regards
Yan Cheng CHEOK

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Geoghegan 2010-12-15 15:20:08 Re: Linux: PAE or x64
Previous Message Andrus Moor 2010-12-15 15:15:02 Re: How to restore from backup to 8.4.3 server using 9.0 dump/restore