Move tablespace - Mailing list pgsql-hackers

From Simon Riggs
Subject Move tablespace
Date
Msg-id 1271790989.8305.24713.camel@ebony
Whole thread Raw
Responses Re: Move tablespace  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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

pgsql-hackers by date:

Previous
From: Dave Page
Date:
Subject: Re: BETA
Next
From: Alvaro Herrera
Date:
Subject: Re: Thoughts on pg_hba.conf rejection