Re: Downtime-free 'alter table set tablespace'

From: Vincent de Phily <vincent(dot)dephily(at)mobile-devices(dot)fr>
To: pgsql-general(at)postgresql(dot)org
Cc: Chris Ernst <cernst(at)zvelo(dot)com>
Subject: Re: Downtime-free 'alter table set tablespace'
Date: 2014-05-27 18:31:38
Message-ID: 2256517.cOd3eHV5mY@moltowork
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday 23 May 2014 15:12:47 Chris Ernst wrote:
> On 05/23/2014 08:57 AM, Vincent de Phily wrote:
> > I need to reduce downtime to a minimum, so I can't afford to let "alter
> > table set tablespace" take an exclusive lock on the table for the 2h
> > it'll take to copy the data.
>
> You might look at pg_repack (https://github.com/reorg/pg_repack) The
> most recent version added the ability to repack a table (or just
> indexes) to a new tablespace. It won't be fast as it will essentially
> rebuild the entire table. But it only needs an exclusive lock for a
> brief moment, so there's virtually zero down time and no data loss.
>
> - Chris

That's pretty much what I was looking for, thanks. It's not perfect because it
still requires a fair amount of temporary space on the origin tablespace, but
it does the job in a cleaner way than what I was attempting.

Thanks Jerry too for the slony suggestion, I didn't think slony (which I've
used a bit) supported replicating to the same db in a different table name.

It'd still be nice to get support in core for "set tablespace concurrently"
because it has the potential to be much more efficient, but beggers can't be
choosers :p

--
Vincent de Phily

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vincent de Phily 2014-05-27 18:48:04 Re: Receiving many more rows than expected
Previous Message Paul Jones 2014-05-27 18:30:46 Code for user-defined type