Skip site navigation (1) Skip section navigation (2)

skip WAL on COPY patch

From: Steve Singer <ssinger(at)ca(dot)afilias(dot)info>
To: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: skip WAL on COPY patch
Date: 2011-08-23 17:48:05
Message-ID: 4E53E7D5.6030808@ca.afilias.info (view raw or flat)
Thread:
Lists: pgsql-hackers
The attached patch adds an option to the COPY command to skip writing 
WAL when the following conditions are all met:

1) The table is empty (zero size on disk)
2) The copy command can obtain an access exclusive lock on the table 
with out blocking.
3) The WAL isn't needed for replication

For example

COPY a FROM '/tmp/a.txt' (SKIP_WAL);

A non-default option to the copy command is required because the copy 
will block out any concurrent access to the table which would be 
undesirable in some cases and is different from the current behaviour.

This can safely be done because if the transaction does not commit the 
empty version of the data files are still available.  The COPY command 
already skips WAL if the table was created in the current transaction.


There was a discussion on something similar before[1] but I didn't see 
any discussion of having it only obtain the lock if it can do so without 
waiting (nor could I find in the archives what happened to that patch). 
  I'm not attached to the SKIP_WAL vs LOCK as the option


1- see http://archives.postgresql.org/pgsql-patches/2005-12/msg00206.php

Steve

Attachment: skip_wal_copy.diff
Description: text/x-patch (11.0 KB)

Responses

pgsql-hackers by date

Next:From: Kevin GrittnerDate: 2011-08-23 18:07:33
Subject: Re: SSI 2PC coverage
Previous:From: Jeff DavisDate: 2011-08-23 17:23:28
Subject: Range Types

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group