From: | Darren Duncan <darren(at)darrenduncan(dot)net> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: SQL Programming Question |
Date: | 2010-09-11 18:20:22 |
Message-ID: | 4C8BC866.1030702@darrenduncan.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Martin Gainty wrote:
> -- i usually
> INSERT the record
> --then check for PK VIOLATION e.g.
> IF PK_VIOLATION then UPDATE record
>
> is FoxPro still supported???
My understanding is that exception handling carries significant overhead and so
doing it within a heavy-iterated loop like this import would perform badly.
Partly for that reason and partly for code readability, I would recommend
instead the suggestion of copy the whole source to a staging table with COPY and
then use a single SQL statement to reconcile/integrate that staging table with
the main table.
In particular, I like the staging table approach because the single SQL
statement afterwards is a concise declarational code saying what you actually
want to do, relative to a client-interfacing loop which is a more verbose
imperative version.
-- Darren Duncan
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2010-09-11 19:26:22 | Re: SQL Programming Question |
Previous Message | Jeff Davis | 2010-09-11 17:48:32 | Re: Regular expression that splits CSV string into table |