Re: COPY FROM - to avoid WAL generation

From: Andres Freund <andres(at)anarazel(dot)de>
To: Ravi Krishna <sravikrishna(at)aol(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: COPY FROM - to avoid WAL generation
Date: 2018-08-21 15:31:28
Message-ID: 20180821153128.uwjx724qvu2e5thz@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

On 2018-08-21 15:00:03 +0000, Ravi Krishna wrote:
> In a recent thread of mine I learned something very interesting.  If a table is created and data is loaded via COPY FROM within the same transaction, then PG will be smart enough to not generate WAL logs because all it needs to do is to track the status of the transaction and let the data load go to the new data file created for the table.  If committed, the table is released for other sessions, if rolledback, vaccum will delete the data file later on.
> I tested it as follows for a table with 50 milllion rows.  No indexes.

Please note this is only the case if wal_level = minimal. If replication
(or PITR) is supported, that mode can't be used, because the data has to
go into the WAL.

Were you using wal_level = minimal?

(FWIW, it's not VACUUM that'd unlink the data in cause of failure, but
that doesn't really matter much).

Greetings,

Andres Freund

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ravi Krishna 2018-08-21 15:42:48 Re: COPY FROM - to avoid WAL generation
Previous Message Jeff Ross 2018-08-21 15:26:11 Re: COPY FROM - to avoid WAL generation