Skipping WAL acceleration

The purpose of the write-ahead log is to protect you from partially committed data being left behind after a crash. If you create a new table in a transaction, add some data to it, and then commit at the end, at no point during that process is the WAL really necessary. If the commit doesn't happen, the expectation is that the entire table is gone anyway. Accordingly, in recent PostgreSQL versions this particular case is accelerated. A bulk load is as follows:

BEGIN;
CREATE TABLE t ...
COPY t FROM ...
COMMIT;

It will not generate any WAL records by default, and therefore execute quicker. You can get the same acceleration with a table that exists if you use TRUNCATE to clear it out first.

However, if you have turned ...

Get PostgreSQL 10 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.