Re: count(*) slow on large tables

From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Jeff <threshar(at)torgo(dot)978(dot)org>
Cc: Christopher Browne <cbbrowne(at)acm(dot)org>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: count(*) slow on large tables
Date: 2003-10-04 09:37:32
Message-ID: 3F7E94DC.9090709@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-performance


> On our message boards each post is a row. The powers that be like to know
> how many posts there are total (In addition to 'today')-
> select count(*) from posts is how it has been
> done on our informix db. With our port to PG I instead select reltuples
> pg_class.

We have exactly the same situation, except we just added a 'num_replies'
field to each thread and a 'num_posts' field to each forum, so that
getting that information out is a very fast operation. Because, of
course, there are hundreds of times more reads of that information than
writes...

Chris

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2003-10-04 09:38:39 Re: Weird locking situation
Previous Message Christopher Kings-Lynne 2003-10-04 09:35:18 Re: Quick question

Browse pgsql-performance by date

  From Date Subject
Next Message Jeff 2003-10-04 12:56:35 Re: Tuning/performance issue...
Previous Message Hannu Krosing 2003-10-04 09:00:04 Re: [HACKERS] Index/Function organized table layout (from Re: