Move tablespace

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Move tablespace
Date: 2010-04-20 19:16:29
Message-ID: 1271790989.8305.24713.camel@ebony
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


I just noticed that

ALTER TABLE foo SET TABLESPACE new_tablespace;

doesn't optimise writing WAL, so when streaming enabled it will copy the
whole table to WAL and across the wire. My understanding was that ALTER
TABLE had been optimised, though not as much as could be in this case.

Following patch writes a new WAL record that just says "copy foo to
newts" and during replay we flush buffers and then re-execute the copy
(but only when InArchiveRecovery). So the copy happens locally on the
standby, not copying from primary to standby. We do this just with a
little refactoring and a simple new WAL message.

So about 64 bytes rather than potentially gigabytes of data, which seems
important when using SR.

Simple patch, no new concepts, so I figure to apply this now.
(Yes, I need to bump WAL format id as well).

Objections?

--
Simon Riggs www.2ndQuadrant.com

Attachment Content-Type Size
move_tablespace.patch text/x-patch 11.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2010-04-20 19:30:28 Re: Thoughts on pg_hba.conf rejection
Previous Message Dave Page 2010-04-20 18:31:47 Re: BETA