Re: discard on constraint violation - Mailing list pgsql-general

From David Johnston
Subject Re: discard on constraint violation
Date
Msg-id 005b01cc34d3$91c36fb0$b54a4f10$@yahoo.com
Whole thread Raw
In response to discard on constraint violation  (Sim Zacks <sim@compulab.co.il>)
List 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.




pgsql-general by date:

Previous
From: Radoslaw Smogura
Date:
Subject: Re: Reusing cached prepared statement slow after 5 executions
Next
From: "David Johnston"
Date:
Subject: Re: to_timestamp() and timestamp without time zone