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

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 (view raw or flat)
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: move_tablespace.patch
Description: text/x-patch (11.9 KB)

Responses

pgsql-hackers by date

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

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