pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Disk space consumed by pk not returned after vacuum or reindex
7+ messages / 3 participants
[nested] [flat]

* Disk space consumed by pk not returned after vacuum or reindex
@ 2006-09-13 13:53 Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-09-22 17:05 ` Re: Disk space consumed by pk not returned after vacuum or reindex Bruno Wolff III <bruno@wolff.to>
  0 siblings, 1 reply; 7+ messages in thread

From: Kevin Johnson @ 2006-09-13 13:53 UTC (permalink / raw)
  To: pgsql-admin; +Cc: Sean Webb <Sean.Webb@noaa.gov>

Hello,

I am running into a problem on a RHEL3 systems, running PostgreSQL 7.4

We have a database, which consistently consumes more and more of the 
disk space in it's lvol until it reaches 100%.  So far, we have tried to 
run a full vacuum on the database, with limited success.  Eventually, we 
had to drop and reload the database with the same data inside.  It 
brought the disk usage down to 73%.  It then began to creep once more 
toward 100%.  After some research, I was able to use the pg_class 
catalog to find that the items which are expanding the quickest are 
primary key (btree) indexes.  I attempted to run a REINDEX on one of the 
tables with the pk taking up the largest amount of space.  The usage 
according to pg_class dropped dramatically, however the disk space was 
not returned to the system.  So I attempted another full vacuum 
afterwards, and still nothing was returned to the system.  These tables 
are updated extremely frequently (although their total number of rows is 
close to constant), which is my guess as to why the pk indexes increase 
so rapidly in terms of their disk usage.  Unfortunately, PostgreSQL 
knowledge is limited, and I was wondering if anyone had experienced 
something similar / knows what else we can do to return this disk space 
back to the system?

Thank you in advance for any/all help!

Kevin

Attachments:

Kevin.Johnson.vcf (text/x-vcard, 284B) download begin:vcard fn:Kevin Johnson n:Johnson;Kevin org:Raytheon AWIPS Team adr:SMCC II;;;1325 East West Highway;Silver Spring;MD;20910 email;internet:Kevin.Johnson@noaa.gov title:Sr. Systems Engineer tel;work:301.713.9362 x325 tel;cell:301.787.0648 x-mozilla-html:TRUE version:2.1 end:vcard
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: Disk space consumed by pk not returned after vacuum or reindex
  2006-09-13 13:53 Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
@ 2006-09-22 17:05 ` Bruno Wolff III <bruno@wolff.to>
  2006-10-05 16:24   ` Re: Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
  0 siblings, 1 reply; 7+ messages in thread

From: Bruno Wolff III @ 2006-09-22 17:05 UTC (permalink / raw)
  To: Kevin Johnson <Kevin.Johnson@noaa.gov>; +Cc: pgsql-admin@postgresql.org, Sean Webb <Sean.Webb@noaa.gov>

On Wed, Sep 13, 2006 at 09:53:16 -0400,
  Kevin Johnson <Kevin.Johnson@noaa.gov> wrote:
> 
> We have a database, which consistently consumes more and more of the 
> disk space in it's lvol until it reaches 100%.  So far, we have tried to 
> run a full vacuum on the database, with limited success.  Eventually, we 
> had to drop and reload the database with the same data inside.  It 
> brought the disk usage down to 73%.  It then began to creep once more 
> toward 100%.  After some research, I was able to use the pg_class 
> catalog to find that the items which are expanding the quickest are 
> primary key (btree) indexes.  I attempted to run a REINDEX on one of the 
> tables with the pk taking up the largest amount of space.  The usage 
> according to pg_class dropped dramatically, however the disk space was 
> not returned to the system.  So I attempted another full vacuum 
> afterwards, and still nothing was returned to the system.  These tables 
> are updated extremely frequently (although their total number of rows is 
> close to constant), which is my guess as to why the pk indexes increase 
> so rapidly in terms of their disk usage.  Unfortunately, PostgreSQL 
> knowledge is limited, and I was wondering if anyone had experienced 
> something similar / knows what else we can do to return this disk space 
> back to the system?

This is possibly index bloat due to new keys always being larger than existing
keys. This was fixed in later releases. There is still some potential for
bloat due to fragmentation, but I believe that has a constant bound.
You might try using the cluster command. I think that will both clean up
the indexes and remove dead rows and do it faster than using a vacuum full
and reindexing. The downside is that the table will be unavailable during
the cluster which might be a deal breaker for you.



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Disk space consumed by pk not returned after vacuum or reindex
  2006-09-13 13:53 Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-09-22 17:05 ` Re: Disk space consumed by pk not returned after vacuum or reindex Bruno Wolff III <bruno@wolff.to>
@ 2006-10-05 16:24   ` Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-10-06 01:29     ` Re: Disk space consumed by pk not returned after vacuum or reindex Jim Nasby <jimn@enterprisedb.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Kevin Johnson @ 2006-10-05 16:24 UTC (permalink / raw)
  To: Bruno Wolff III <bruno@wolff.to>; pgsql-admin@postgresql.org, Sean Webb <Sean.Webb@noaa.gov>

Thank you for the suggestion, Bruno. The clustering did the trick in 
reducing the current disk usage, however eventually the disk space get 
consumed once more. I fear that we may just need to update the version 
of Postgres to help alleviate index bloat!


Bruno Wolff III wrote:
> On Wed, Sep 13, 2006 at 09:53:16 -0400,
>   Kevin Johnson <Kevin.Johnson@noaa.gov> wrote:
>   
>> We have a database, which consistently consumes more and more of the 
>> disk space in it's lvol until it reaches 100%.  So far, we have tried to 
>> run a full vacuum on the database, with limited success.  Eventually, we 
>> had to drop and reload the database with the same data inside.  It 
>> brought the disk usage down to 73%.  It then began to creep once more 
>> toward 100%.  After some research, I was able to use the pg_class 
>> catalog to find that the items which are expanding the quickest are 
>> primary key (btree) indexes.  I attempted to run a REINDEX on one of the 
>> tables with the pk taking up the largest amount of space.  The usage 
>> according to pg_class dropped dramatically, however the disk space was 
>> not returned to the system.  So I attempted another full vacuum 
>> afterwards, and still nothing was returned to the system.  These tables 
>> are updated extremely frequently (although their total number of rows is 
>> close to constant), which is my guess as to why the pk indexes increase 
>> so rapidly in terms of their disk usage.  Unfortunately, PostgreSQL 
>> knowledge is limited, and I was wondering if anyone had experienced 
>> something similar / knows what else we can do to return this disk space 
>> back to the system?
>>     
>
> This is possibly index bloat due to new keys always being larger than existing
> keys. This was fixed in later releases. There is still some potential for
> bloat due to fragmentation, but I believe that has a constant bound.
> You might try using the cluster command. I think that will both clean up
> the indexes and remove dead rows and do it faster than using a vacuum full
> and reindexing. The downside is that the table will be unavailable during
> the cluster which might be a deal breaker for you.
>   

-- 
Kevin Johnson
Raytheon
AWIPS Sr. Systems Engineer
NWS Network Control Facility
p: 301.713.9362x325
f: 301.713.1905

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Disk space consumed by pk not returned after vacuum or reindex
  2006-09-13 13:53 Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-09-22 17:05 ` Re: Disk space consumed by pk not returned after vacuum or reindex Bruno Wolff III <bruno@wolff.to>
  2006-10-05 16:24   ` Re: Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
@ 2006-10-06 01:29     ` Jim Nasby <jimn@enterprisedb.com>
  2006-10-06 10:39       ` Re: Disk space consumed by pk not returned after vacuum or Kevin Johnson <Kevin.Johnson@noaa.gov>
  0 siblings, 1 reply; 7+ messages in thread

From: Jim Nasby @ 2006-10-06 01:29 UTC (permalink / raw)
  To: Kevin Johnson <Kevin.Johnson@noaa.gov>; +Cc: Bruno Wolff III <bruno@wolff.to>; pgsql-admin@postgresql.org, Sean Webb <Sean.Webb@noaa.gov>

I didn't see you mention what version you're running; index bloat  
shouldn't be a big issue in 7.4 and above. You also didn't mention  
how often you're vacuuming the table. If you don't vacuum the table  
frequently enough, you're going to get bloat, plain and simple.

On Oct 5, 2006, at 11:24 AM, Kevin Johnson wrote:
> Thank you for the suggestion, Bruno.  The clustering did the trick  
> in reducing the current disk usage, however eventually the disk  
> space get consumed once more.  I fear that we may just need to  
> update the version of Postgres to help alleviate index bloat!
>
> Bruno Wolff III wrote:
>> On Wed, Sep 13, 2006 at 09:53:16 -0400, Kevin Johnson  
>> <Kevin.Johnson@noaa.gov> wrote:
>>> We have a database, which consistently consumes more and more of  
>>> the disk space in it's lvol until it reaches 100%. So far, we  
>>> have tried to run a full vacuum on the database, with limited  
>>> success. Eventually, we had to drop and reload the database with  
>>> the same data inside. It brought the disk usage down to 73%. It  
>>> then began to creep once more toward 100%. After some research, I  
>>> was able to use the pg_class catalog to find that the items which  
>>> are expanding the quickest are  primary key (btree) indexes. I  
>>> attempted to run a REINDEX on one of the tables with the pk  
>>> taking up the largest amount of space. The usage according to  
>>> pg_class dropped dramatically, however the disk space was not  
>>> returned to the system. So I attempted another full vacuum  
>>> afterwards, and still nothing was returned to the system. These  
>>> tables are updated extremely frequently (although their total  
>>> number of rows is close to constant), which is my guess as to why  
>>> the pk indexes increase so rapidly in terms of their disk usage.  
>>> Unfortunately, PostgreSQL knowledge is limited, and I was  
>>> wondering if anyone had experienced something similar / knows  
>>> what else we can do to return this disk space back to the system?
>> This is possibly index bloat due to new keys always being larger  
>> than existing keys. This was fixed in later releases. There is  
>> still some potential for bloat due to fragmentation, but I believe  
>> that has a constant bound. You might try using the cluster  
>> command. I think that will both clean up the indexes and remove  
>> dead rows and do it faster than using a vacuum full and  
>> reindexing. The downside is that the table will be unavailable  
>> during the cluster which might be a deal breaker for you.
--
Jim Nasby                                            jim@nasby.net
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)


--
Jim Nasby                                    jimn@enterprisedb.com
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Disk space consumed by pk not returned after vacuum or
  2006-09-13 13:53 Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-09-22 17:05 ` Re: Disk space consumed by pk not returned after vacuum or reindex Bruno Wolff III <bruno@wolff.to>
  2006-10-05 16:24   ` Re: Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-10-06 01:29     ` Re: Disk space consumed by pk not returned after vacuum or reindex Jim Nasby <jimn@enterprisedb.com>
@ 2006-10-06 10:39       ` Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-10-06 15:37         ` Re: Disk space consumed by pk not returned after vacuum or reindex Jim Nasby <jimn@enterprisedb.com>
  2006-10-06 19:01         ` Re: Disk space consumed by pk not returned after vacuum or Bruno Wolff III <bruno@wolff.to>
  0 siblings, 2 replies; 7+ messages in thread

From: Kevin Johnson @ 2006-10-06 10:39 UTC (permalink / raw)
  To: Jim Nasby <jimn@enterprisedb.com>; +Cc: Bruno Wolff III <bruno@wolff.to>; pgsql-admin@postgresql.org, Sean Webb <Sean.Webb@noaa.gov>

You are correct, it is 7.4 we are running on a RHEL3 system.
The database itself is vacuumed via cron 6 times a day. 

Jim Nasby wrote:
> I didn't see you mention what version you're running; index bloat 
> shouldn't be a big issue in 7.4 and above. You also didn't mention how 
> often you're vacuuming the table. If you don't vacuum the table 
> frequently enough, you're going to get bloat, plain and simple.
>
> On Oct 5, 2006, at 11:24 AM, Kevin Johnson wrote:
>> Thank you for the suggestion, Bruno.  The clustering did the trick in 
>> reducing the current disk usage, however eventually the disk space 
>> get consumed once more.  I fear that we may just need to update the 
>> version of Postgres to help alleviate index bloat!
>>
>> Bruno Wolff III wrote:
>>> On Wed, Sep 13, 2006 at 09:53:16 -0400, Kevin Johnson 
>>> <Kevin.Johnson@noaa.gov> wrote:
>>>> We have a database, which consistently consumes more and more of 
>>>> the disk space in it's lvol until it reaches 100%. So far, we have 
>>>> tried to run a full vacuum on the database, with limited success. 
>>>> Eventually, we had to drop and reload the database with the same 
>>>> data inside. It brought the disk usage down to 73%. It then began 
>>>> to creep once more toward 100%. After some research, I was able to 
>>>> use the pg_class catalog to find that the items which are expanding 
>>>> the quickest are  primary key (btree) indexes. I attempted to run a 
>>>> REINDEX on one of the tables with the pk taking up the largest 
>>>> amount of space. The usage according to pg_class dropped 
>>>> dramatically, however the disk space was not returned to the 
>>>> system. So I attempted another full vacuum afterwards, and still 
>>>> nothing was returned to the system. These tables are updated 
>>>> extremely frequently (although their total number of rows is close 
>>>> to constant), which is my guess as to why the pk indexes increase 
>>>> so rapidly in terms of their disk usage. Unfortunately, PostgreSQL 
>>>> knowledge is limited, and I was wondering if anyone had experienced 
>>>> something similar / knows what else we can do to return this disk 
>>>> space back to the system?
>>> This is possibly index bloat due to new keys always being larger 
>>> than existing keys. This was fixed in later releases. There is still 
>>> some potential for bloat due to fragmentation, but I believe that 
>>> has a constant bound. You might try using the cluster command. I 
>>> think that will both clean up the indexes and remove dead rows and 
>>> do it faster than using a vacuum full and reindexing. The downside 
>>> is that the table will be unavailable during the cluster which might 
>>> be a deal breaker for you.
> -- 
> Jim Nasby                                            jim@nasby.net
> EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)
>
>
> -- 
> Jim Nasby                                    jimn@enterprisedb.com
> EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)
>
>

-- 
Kevin Johnson
Raytheon
AWIPS Sr. Systems Engineer
NWS Network Control Facility
p: 301.713.9362x325
f: 301.713.1905

Attachments:

Kevin.Johnson.vcf (text/x-vcard, 284B) download begin:vcard fn:Kevin Johnson n:Johnson;Kevin org:Raytheon AWIPS Team adr:SMCC II;;;1325 East West Highway;Silver Spring;MD;20910 email;internet:Kevin.Johnson@noaa.gov title:Sr. Systems Engineer tel;work:301.713.9362 x325 tel;cell:301.787.0648 x-mozilla-html:TRUE version:2.1 end:vcard
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: Disk space consumed by pk not returned after vacuum or reindex
  2006-09-13 13:53 Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-09-22 17:05 ` Re: Disk space consumed by pk not returned after vacuum or reindex Bruno Wolff III <bruno@wolff.to>
  2006-10-05 16:24   ` Re: Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-10-06 01:29     ` Re: Disk space consumed by pk not returned after vacuum or reindex Jim Nasby <jimn@enterprisedb.com>
  2006-10-06 10:39       ` Re: Disk space consumed by pk not returned after vacuum or Kevin Johnson <Kevin.Johnson@noaa.gov>
@ 2006-10-06 15:37         ` Jim Nasby <jimn@enterprisedb.com>
  1 sibling, 0 replies; 7+ messages in thread

From: Jim Nasby @ 2006-10-06 15:37 UTC (permalink / raw)
  To: Kevin Johnson <Kevin.Johnson@noaa.gov>; +Cc: Bruno Wolff III <bruno@wolff.to>; pgsql-admin@postgresql.org, Sean Webb <Sean.Webb@noaa.gov>

On Oct 6, 2006, at 5:39 AM, Kevin Johnson wrote:
> You are correct, it is 7.4 we are running on a RHEL3 system.
> The database itself is vacuumed via cron 6 times a day.
>
> Jim Nasby wrote:
>> I didn't see you mention what version you're running; index bloat  
>> shouldn't be a big issue in 7.4 and above. You also didn't mention  
>> how often you're vacuuming the table. If you don't vacuum the  
>> table frequently enough, you're going to get bloat, plain and simple.

For a heavy update load, even 6 times a day may not be enough.

Also, remember that the size you get after a REINDEX will be  
unreasonably low, because there will be very little free space in the  
index. That's fine if you won't be updating the table much, but  
otherwise the index will have no choice but to grow.
--
Jim Nasby                                    jimn@enterprisedb.com
EnterpriseDB      http://enterprisedb.com      512.569.9461 (cell)





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Disk space consumed by pk not returned after vacuum or
  2006-09-13 13:53 Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-09-22 17:05 ` Re: Disk space consumed by pk not returned after vacuum or reindex Bruno Wolff III <bruno@wolff.to>
  2006-10-05 16:24   ` Re: Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
  2006-10-06 01:29     ` Re: Disk space consumed by pk not returned after vacuum or reindex Jim Nasby <jimn@enterprisedb.com>
  2006-10-06 10:39       ` Re: Disk space consumed by pk not returned after vacuum or Kevin Johnson <Kevin.Johnson@noaa.gov>
@ 2006-10-06 19:01         ` Bruno Wolff III <bruno@wolff.to>
  1 sibling, 0 replies; 7+ messages in thread

From: Bruno Wolff III @ 2006-10-06 19:01 UTC (permalink / raw)
  To: Kevin Johnson <Kevin.Johnson@noaa.gov>; +Cc: Jim Nasby <jimn@enterprisedb.com>; pgsql-admin@postgresql.org, Sean Webb <Sean.Webb@noaa.gov>

On Fri, Oct 06, 2006 at 06:39:40 -0400,
  Kevin Johnson <Kevin.Johnson@noaa.gov> wrote:
> You are correct, it is 7.4 we are running on a RHEL3 system.
> The database itself is vacuumed via cron 6 times a day. 

The other thing you need to watch out for is that your FSM setting is
large enough to recover all of the dead space. If your vacuum runs aren't
recovering as much dead space as is being created on average, then you are
going to have dead space accumalate.



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2006-10-06 19:01 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-09-13 13:53 Disk space consumed by pk not returned after vacuum or reindex Kevin Johnson <Kevin.Johnson@noaa.gov>
2006-09-22 17:05 ` Bruno Wolff III <bruno@wolff.to>
2006-10-05 16:24   ` Kevin Johnson <Kevin.Johnson@noaa.gov>
2006-10-06 01:29     ` Jim Nasby <jimn@enterprisedb.com>
2006-10-06 10:39       ` Re: Disk space consumed by pk not returned after vacuum or Kevin Johnson <Kevin.Johnson@noaa.gov>
2006-10-06 15:37         ` Jim Nasby <jimn@enterprisedb.com>
2006-10-06 19:01         ` Re: Disk space consumed by pk not returned after vacuum or Bruno Wolff III <bruno@wolff.to>

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