From: | François Beausoleil <francois(at)teksol(dot)info> |
---|---|
To: | Forums postgresql <pgsql-general(at)postgresql(dot)org> |
Subject: | DELETE or TRUNCATE? |
Date: | 2013-05-16 14:22:26 |
Message-ID: | E0C28CD9-4FA9-4C00-A6D2-9C9FE88DF2CC@teksol.info |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi!
I have a process that replaces the contents of a table. The canonical data store is somewhere else. At the moment, the import looks like this:
CREATE TEMPORARY TABLE markets_import( LIKE x INCLUDING ALL );
COPY markets_import FROM STDIN;
...
\.
-- COPY a bunch of other tables
BEGIN;
TRUNCATE markets;
INSERT INTO markets SELECT * FROM markets_import;
-- do the other tables here as well
COMMIT;
VACUUM ANALYZE markets;
Sometimes, the import process will block on the TRUNCATE because some other query already holds a ShareLock on the markets table, because it's doing a long report. I'm guessing TRUNCATE prevents the use of MVCC, and DELETE would be better in this case? Especially since I'm doing a VACUUM ANALYZE at the end anyway.
Thanks!
François
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2013-05-16 14:27:36 | Re: FATAL: database "a/system_data" does not exist |
Previous Message | Ioana Danes | 2013-05-16 14:13:32 | Re: Running out of memory at vacuum |