DELETE followed by INSERT in the same transaction is producing unexpected results.

From: "Ezra Epstein" <eepstein(at)prajnait(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: DELETE followed by INSERT in the same transaction is producing unexpected results.
Date: 2004-01-13 00:30:20
Message-ID: GJEMKNGMHLIGIBLPFHCPKEJDCCAA.eepstein@prajnait.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've got a rather simple load script that makes use of the COPY command to
get some data into a DB. All good.

I wrote an equally simple "reload" script that for one table simply does a
DELETE and then calls the load script. The 2 must happen in the same
transaction since there is a DEFERRED cascade delete on a FK that I do not
want triggered. (I.e., the reload mostly recreates records with the same
PKs, though with changes to other columns.) At the end of the reload the
table in question is empty! Mid-way through (before commit) a SELECT
count(*) on the table reports the expected number of rows. No
error/exception occurs during the procedure. NOTE: I tried adding an oid
column to the table and that did not fix the problem.

[ Another, secondary, thing is that this process is terribly slow ( 90
seconds for 800 rows of data !). Yes, there are some indices on the table,
but I figured COPY might be smart and have indices recomputed in bulk not
per-row ?? -- and, dropping then re-applying the indices doesn't speed
things up very much: the blockage again seems to be the delete and insert in
the same x-action. ]

Any clues?

Thx,

== Ezra Epstein

Attachment Content-Type Size
test_reload.sql text/plain 1.8 KB

Browse pgsql-general by date

  From Date Subject
Next Message Alex Satrapa 2004-01-13 00:32:22 Re: sql insert function
Previous Message Chris Ochs 2004-01-13 00:29:51 Re: sql insert function