pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Smith <gsmith@gregsmith.com>
To: pgsql-performance@postgresql.org
Subject: Re: count * performance issue
Date: Sat, 8 Mar 2008 00:08:39 -0500 (EST)
Message-ID: <Pine.GSO.4.64.0803072348050.4777@westnet.com> (raw)
In-Reply-To: <13345.1204940295@sss.pgh.pa.us>
References: <f966c2ee0803052142l6a105678jfe2da92a0d9371@mail.gmail.com>
	<47D00DB2.7040007@emolecules.com>
	<18451.1204824562@sss.pgh.pa.us>
	<200803071727.36146.josh@agliodbs.com>
	<13345.1204940295@sss.pgh.pa.us>

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



view thread (62+ messages)  latest in thread

Message-ID: <Pine.GSO.4.64.0803072348050.4777@westnet.com>
Permalink:  ../Pine.GSO.4.64.0803072348050.4777@westnet.com/
Also on:    postgresql.org/message-id/Pine.GSO.4.64.0803072348050.4777@westnet.com

 · 

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: gsmith@gregsmith.com
  Subject: Re: count * performance issue
  In-Reply-To: <Pine.GSO.4.64.0803072348050.4777@westnet.com>

* 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