Re: count * performance issue - Mailing list pgsql-performance

From Greg Smith
Subject Re: count * performance issue
Date
Msg-id Pine.GSO.4.64.0803072348050.4777@westnet.com
Whole thread Raw
In response to Re: count * performance issue  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: count * performance issue  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
On Fri, 7 Mar 2008, Tom Lane wrote:

> Well, scanning an index to get a count might be significantly faster
> than scanning the main table, but it's hardly "instantaneous".  It's
> still going to take time proportional to the table size.

If this is something that's happening regularly, you'd have to hope that
most of the index is already buffered in memory somewhere though, so now
you're talking a buffer/OS cache scan that doesn't touch disk much.
Should be easier for that to be true because the index is smaller than the
table, right?

I know when I'm playing with pgbench the primary key index on the big
accounts table is 1/7 the size of the table, and when using that table
heavily shared_buffers ends up being mostly filled with that index. The
usage counts are so high on the index blocks relative to any section of
the table itself that they're very sticky in memory.  And that's toy data;
on some of the webapps people want these accurate counts for the ratio of
index size to table data is even more exaggerated (think web forum).

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD

pgsql-performance by date:

Previous
From: "petchimuthu lingam"
Date:
Subject: Re: Confirmação de envio / Sending confirmation (captchaid:13266b402f09)
Next
From: Mark Mielke
Date:
Subject: Re: count * performance issue