Unloading a table consistently

From: Christophe <xof(at)thebuild(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Unloading a table consistently
Date: 2008-05-03 16:11:16
Message-ID: 67F28F8F-CDB5-4F1C-839E-956BF2EA8A6F@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I will have a log table which, once a day or so, is copied to a file
(for movement to a data warehouse), and the log table emptied. For
performance, the log table on the production system has no indexes,
and is write-only. (The unload process is the only reader.)

To unload it, I will be doing:

BEGIN;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
COPY log TO 'filename-path';
TRUNCATE log;
COMMIT;

My understanding is that I need the SERIALIZABLE isolation level so
that the COPY and TRUNCATE see exactly the same view of the table.
Obviously, I don't want to lose data by having the TRUNCATE delete
records that appeared while the COPY was executing. Is that
correct? Is there a better way to handle this kind of thing that I'm
missing?

Thanks!
-- Xof

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-05-03 16:56:57 Re: Unloading a table consistently
Previous Message Sanjaya Kumar Patel 2008-05-03 12:03:36 Re: High resolution PostgreSQL Logo