Re: discard on constraint violation

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Sim Zacks'" <sim(at)compulab(dot)co(dot)il>, "'PostgreSQL general'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: discard on constraint violation
Date: 2011-06-27 14:07:36
Message-ID: 005b01cc34d3$91c36fb0$b54a4f10$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>My situation is that I'm reading data from an external website with lots
of duplicate data. I am reading the data in a plpythonu function. I never
update, only insert. A trigger on the table that has to check if each row
exists before trying the insert is too much overhead.

Create a staging table into which you import your external data and then
write a query of the form "INSERT INTO realtable SELECT FROM stagingtable
WHERE stagingtable NOT EXISTS realtable".

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-06-27 15:00:58 Re: to_timestamp() and timestamp without time zone
Previous Message Radoslaw Smogura 2011-06-27 14:02:22 Re: Reusing cached prepared statement slow after 5 executions