We have a rather specific application that uses PostgreSQL 8.3 as a storage backend (using Python and psycopg2). The operations we perform to the important tables are in the ma
The usual way I do these things in pg is: load raw data matching target table into temp table (no constraints) using copy, merge(the fun part), profit.
I wrote a merge_by_key function specifically for these situations:
http://mbk.projects.postgresql.org/
The docs aren't terribly friendly, but I'd suggest giving it a good look.