Re: full vacuum of a very large table

Поиск
Список
Период
Сортировка
От Bob Lunney
Тема Re: full vacuum of a very large table
Дата
Msg-id 967268.12623.qm@web39705.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на full vacuum of a very large table  ("Nic Chidu" <nic@chidu.net>)
Список pgsql-admin
--- On Tue, 3/29/11, Nic Chidu <nic@chidu.net> wrote:

> From: Nic Chidu <nic@chidu.net>
> Subject: [ADMIN] full vacuum of a very large table
> To: pgsql-admin@postgresql.org
> Date: Tuesday, March 29, 2011, 11:56 AM
> 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?
>
> Thanks,
>
> Nic
>
> --

Nic,

Since you know the where clause to delete the 120 mil rows why not use the converse of that to select the 10 mil rows
toretain into another table, then drop the original table?  No vacuum required! 

Be sure to use the "create table as select..." syntax to avoid WAL during creation of the new table, and use a
transactionto drop the original table and rename the new one.  That way users will be querying the original table right
upuntil the switch over, when they will start using the new table.   

Foreign keys and other constraints may complicate things a bit, so check those out first.  Also, don't forget to index
andanalyze the new table before the switch over. 

Good luck!

Bob Lunney




В списке pgsql-admin по дате отправления:

Предыдущее
От: Steve Crawford
Дата:
Сообщение: Re: full vacuum of a very large table
Следующее
От: Shrinivas Devarkonda
Дата:
Сообщение: Re: full vacuum of a very large table