Re: Really really slow select count(*)

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Greg Smith <greg(at)2ndquadrant(dot)com>
Cc: felix <crucialfelix(at)gmail(dot)com>, sthomas(at)peak6(dot)com, pgsql-performance(at)postgresql(dot)org
Subject: Re: Really really slow select count(*)
Date: 2011-02-04 19:01:08
Message-ID: AANLkTi=NAyNcmhMX5J3X5q2R7KgAO1XkTX=Afue_XZaN@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, Feb 4, 2011 at 11:38 AM, Greg Smith <greg(at)2ndquadrant(dot)com> wrote:
> You don't turn it on; it's a one time operation that does a cleanup.  It is
> by far the easiest way to clean up the mess you have right now.  Moving
> forward, if you have max_fsm_pages set to an appropriate number, you
> shouldn't end up back in this position again.  But VACUUM along won't get
> you out of there, and VACUUM FULL is always a worse way to clean this up
> than CLUSTER.

note that for large, randomly ordered tables, cluster can be pretty
slow, and you might want to do the old:

begin;
select * into temporaryholdingtable order by somefield;
truncate oldtable;
insert into oldtables select * from temporaryholdingtable;
commit;

for fastest performance. I've had Cluster take hours to do that the
above does in 1/4th the time.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Berkus 2011-02-04 19:05:57 Write-heavy pg_stats_collector on mostly idle server
Previous Message Robert Haas 2011-02-04 18:49:44 Re: How to best use 32 15k.7 300GB drives?