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 like the following:
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 on the archive_command
facility to feed WAL segments to a PITR standby, this optimization is disabled. The WAL is in that case the only way to get the data over to the standby system, so it can't be skipped. In PostgreSQL...