pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steve Crawford <scrawford@pinpointresearch.com>
To: Plugge, Joe R. <JRPlugge@west.com>
Cc: Nic Chidu <nic@chidu.net>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: full vacuum of a very large table
Date: Tue, 29 Mar 2011 09:33:03 -0700
Message-ID: <4D9209BF.4010104@pinpointresearch.com> (raw)
In-Reply-To: <BD69807DAE0CE44CA00A8338D0FDD08302F6C1D9CE@oma00cexmbx03.corp.westworlds.com>
References: <1301414165.2351.1435136873@webmail.messagingengine.com>
	<BD69807DAE0CE44CA00A8338D0FDD08302F6C1D9CE@oma00cexmbx03.corp.westworlds.com>

On 03/29/2011 09:04 AM, Plugge, Joe R. wrote:
> Personally, provided you have the room, I would build a new table off to the side and then migrate what you need to keep to the new table, when done, and satisfied that you have all of the candidate rows, ranem the original to table to "x_tablename" and rename the newly created table into place to take over.... if all is good .. simply drop the x_tablename table.
This looks attractive but can cause issues if there are views, 
foreign-keys, etc. that depend on this table.

> -----Original Message-----
> From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Nic Chidu
> Sent: Tuesday, March 29, 2011 10:56 AM
> To: pgsql-admin@postgresql.org
> Subject: [ADMIN] full vacuum of a very large table
>
> Got a situation where a 130 mil rows (137GB) table needs to be brought down in size to  10 mil records (most recent) with the least amount of downtime.
>
> Doing a full vacuum would be faster on:
>   - 120 mil rows deleted and 10 mil active (delete most of them then full vacuum)
>   - 10 mil deleted and 120 mil active. (delete small batches and full vacuum after each delete).
>
> Any other suggestions?
>
The phrase "most recent" leads me to believe this is time-based data. 
This might be a good time to partition your table to avoid this issue in 
the future. If you are clever about it (and try it out on a test 
environment), you might be able to create inherited tables off your main 
table and then move the "live" data from the parent to the child in 
unobtrusive sized chunks. When no live data remains in the parent table, 
truncate the parent table (only).

Moving forward, set up your application/processes to put the data in to 
the appropriately sized (day?, week?, month? year?) child table. When 
the time comes, just archive and drop the child.

Cheers,
Steve




view thread (8+ messages)  latest in thread

Message-ID: <4D9209BF.4010104@pinpointresearch.com>
Permalink:  ../4D9209BF.4010104@pinpointresearch.com/
Also on:    postgresql.org/message-id/4D9209BF.4010104@pinpointresearch.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: scrawford@pinpointresearch.com, JRPlugge@west.com, nic@chidu.net
  Subject: Re: full vacuum of a very large table
  In-Reply-To: <4D9209BF.4010104@pinpointresearch.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox