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

Re: Big delete on big table... now what?

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Bill Moran" <wmoran(at)collaborativefusion(dot)com>
Cc: "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Big delete on big table... now what?
Date: 2008-08-23 00:39:56
Message-ID: (view raw or whole thread)
Lists: pgsql-performance
"Bill Moran" <wmoran(at)collaborativefusion(dot)com> writes:

> "Fernando Hevia" <fhevia(at)ip-tel(dot)com(dot)ar> wrote:
>> Hi list.
>> I have a table with over 30 million rows. Performance was dropping steadily
>> so I moved old data not needed online to an historic table. Now the table
>> has about 14 million rows. I don't need the disk space returned to the OS
>> but I do need to improve performance. Will a plain vacuum do or is a vacuum
>> full necessary?
>> ┬┐Would a vacuum full improve performance at all?
> If you can afford the downtime on that table, cluster would be best.
> If not, do the normal vacuum and analyze.  This is unlikely to improve
> the performance much (although it may shrink the table _some_) but
> regular vacuum will keep performance from getting any worse.

Note that CLUSTER requires enough space to store the new and the old copies of
the table simultaneously. That's the main reason for VACUUM FULL to still

There is also the option of doing something like (assuming id is already an
integer -- ie this doesn't actually change the data):


which will rewrite the whole table. This is effectively the same as CLUSTER
except it doesn't order the table according to an index. It will still require
enough space to hold two copies of the table but it will be significantly

  Gregory Stark
  Ask me about EnterpriseDB's RemoteDBA services!

In response to


pgsql-performance by date

Next:From: Loic PetitDate: 2008-08-23 01:41:27
Subject: Large number of tables slow insert
Previous:From: Bill MoranDate: 2008-08-22 22:44:07
Subject: Re: Big delete on big table... now what?

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