pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kenneth Marshall <ktm@rice.edu>
To: felix <crucialfelix@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Really really slow select count(*)
Date: Fri, 4 Feb 2011 10:27:02 -0600
Message-ID: <20110204162702.GE1261@aart.is.rice.edu> (raw)
In-Reply-To: <AANLkTikp3_mvRx+NVvPEbUDcML15BDFdFfL6wPvRyKmd@mail.gmail.com>
References: <AANLkTinAJcm5A+i1O_R87aiYyu8N2OWgoaL9RfR=tUR9@mail.gmail.com>
	<4D4C138C.7010304@2ndquadrant.com>
	<AANLkTi=zNn9hUYAFpgMZSFucfFW92WWbRorRZd1h=SQz@mail.gmail.com>
	<AANLkTikp3_mvRx+NVvPEbUDcML15BDFdFfL6wPvRyKmd@mail.gmail.com>

On Fri, Feb 04, 2011 at 05:20:27PM +0100, felix wrote:
> reply was meant for the list
> 
> ---------- Forwarded message ----------
> From: felix <crucialfelix@gmail.com>
> Date: Fri, Feb 4, 2011 at 4:39 PM
> Subject: Re: [PERFORM] Really really slow select count(*)
> To: Greg Smith <greg@2ndquadrant.com>
> 
> 
> 
> 
> On Fri, Feb 4, 2011 at 3:56 PM, Greg Smith <greg@2ndquadrant.com> wrote:
> 
> > PostgreSQL version?  If you're running on 8.3 or earlier, I would be
> > suspicous that your Free Space Map has been overrun.
> >
> 
> 8.3
> 
> 
> 
> >
> > What you are seeing is that the table itself is much larger on disk than
> > it's supposed to be.
> >
> 
> which part of the explain told you that ?
> 
> > shaun thomas
> 
> SELECT relpages*8/1024 FROM pg_class
>  WHERE relname='fastadder_fastadderstatus';
> 
> 458MB
> 
> way too big. build_cache is text between 500-1k chars
> 

As has been suggested, you really need to CLUSTER the table
to remove dead rows. VACUUM will not do that, VACUUM FULL will
but will take a full table lock and then you would need to
REINDEX to fix index bloat. CLUSTER will do this in one shot.
You almost certainly have your free space map way too small,
which is how you bloated in the first place.

Cheers,
Ken



view thread (66+ messages)  latest in thread

Message-ID: <20110204162702.GE1261@aart.is.rice.edu>
Permalink:  ../20110204162702.GE1261@aart.is.rice.edu/
Also on:    postgresql.org/message-id/20110204162702.GE1261@aart.is.rice.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: ktm@rice.edu, crucialfelix@gmail.com
  Subject: Re: Really really slow select count(*)
  In-Reply-To: <20110204162702.GE1261@aart.is.rice.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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