Re: strange table disk sizes - Mailing list pgsql-general

From Scott Marlowe
Subject Re: strange table disk sizes
Date
Msg-id CAOR=d=2vSSFCdw=sF9QzFBiEboaH9eLu7ZKdCZLvJjWUcqTZMw@mail.gmail.com
Whole thread Raw
In response to strange table disk sizes  (Rik Bellens <rik.bellens@telin.ugent.be>)
Responses Re: strange table disk sizes  (Rik Bellens <rik.bellens@telin.ugent.be>)
List pgsql-general
On Thu, Sep 1, 2011 at 4:32 AM, Rik Bellens <rik.bellens@telin.ugent.be> wrote:
>
> Hello,
>
> I have two large tables in a database, one containing original data and the
> other one derived from the first table. The first table contains several
> columns and indexes, while the second table has less columns and only one
> index. Both tables have the same number of rows. Nevertheless, the second
> table is much larger in disk size than the first one. How can this be
> explained?

This is most likely due to table bloat.  In PostgreSQL when you update
or delete a row, a dead version gets left behind.  Vacuum eventually
comes along and reclaims the empty space to be reused.  If you delete
/ update a LOT of rows at once, then you'll have a lot of dead rows
which can only be reused after vacuuming when you do more updates or
deletes later on.

A few salient questions. What version of PostgreSQL are you running?
Is autovacuum running? Do you do a LOT of bulk deletes / updates?  If
you do a lot of bulk deletes on this table, and you delete everything,
can you switch to using the truncate command instead?

pgsql-general by date:

Previous
From: Sim Zacks
Date:
Subject: Re: md5 of table
Next
From: Sim Zacks
Date:
Subject: Re: md5 of table