Unloading a table consistently - Mailing list pgsql-general

From Christophe
Subject Unloading a table consistently
Date
Msg-id 67F28F8F-CDB5-4F1C-839E-956BF2EA8A6F@thebuild.com
Whole thread Raw
Responses Re: Unloading a table consistently  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Unloading a table consistently  (Reece Hart <reece@harts.net>)
List 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

pgsql-general by date:

Previous
From: Sanjaya Kumar Patel
Date:
Subject: Re: High resolution PostgreSQL Logo
Next
From: Tom Lane
Date:
Subject: Re: Unloading a table consistently