For both cases, you could COPY your file into a temporary table and do a big JOIN with your existing table, one for inserting new rows, and one for updating existing rows. Doing a large bulk query is a lot more efficient than doing a lot of selects. Vacuum afterwards, and you'll be fine.
---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly