pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ravi Krishna <sravikrishna@aol.com>
To: pgsql-general@lists.postgresql.org
Subject: COPY FROM - to avoid WAL generation
Date: Tue, 21 Aug 2018 15:00:03 +0000 (UTC)
Message-ID: <89305671.347835.1534863603311@mail.yahoo.com> (raw)
References: <89305671.347835.1534863603311.ref@mail.yahoo.com>

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.
Case 1  - create the table first.  - in a separate transaction load the 50 million rows.
Took 3 min 22 seconds
Case 2  - start transaction  - create table  - load 50 million rows  - commit transaction
Took: 3 min 16 seconds.
Am I missing anything?

view thread (4+ messages)  latest in thread

Message-ID: <89305671.347835.1534863603311@mail.yahoo.com>
Permalink:  ../89305671.347835.1534863603311@mail.yahoo.com/
Also on:    postgresql.org/message-id/89305671.347835.1534863603311@mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: sravikrishna@aol.com
  Subject: Re: COPY FROM - to avoid WAL generation
  In-Reply-To: <89305671.347835.1534863603311@mail.yahoo.com>
  References: <89305671.347835.1534863603311.ref@mail.yahoo.com> <89305671.347835.1534863603311@mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox