reclaiming space from heavily used tables? - Mailing list pgsql-general

From Rob Nikander
Subject reclaiming space from heavily used tables?
Date
Msg-id 8034843E-CB75-4272-B89D-B9462161275B@gmail.com
Whole thread Raw
Responses Re: reclaiming space from heavily used tables?
List pgsql-general
Hi,

I've got a large table from which I'd like to completely reclaim space. I read the docs and it sounds like I can’t run
`vacuumfull`, because this table is accessed constantly and can’t have downtime. Assuming that’s true, what do you
thinkof the following idea? Is there a better alternative? 

1. Replace the table T with two tables T1 and T2 and a view T that is `select * from T1 union T2`.
2. Write only to T1, and slowly move records from T2 to T1.
3. When T2 is empty, redefine the view T to be simply `select * from T1`.
4. Recreate or vacuum full T2, so space is fully reclaimed.
5. Redefine view as the union select and repeat process going other direction from T1 to T2, as needed.

I guess one question is whether I can do 1 and 3 (renaming tables, redefining views) atomically without disturbing
concurrentselect queries. 

Rob



pgsql-general by date:

Previous
From: Edson Carlos Ericksson Richter
Date:
Subject: Re: PostgreSQL needs percentage function
Next
From: Jeremy Finzel
Date:
Subject: Re: reclaiming space from heavily used tables?