Re: "select count(*) from contacts" is too slow!

Ang Chin Han <angch@bytecraft.com.my>

From: Ang Chin Han <angch@bytecraft.com.my>
To: Christopher Browne <cbbrowne@acm.org>
Cc: pgsql-general@postgresql.org
Date: 2003-10-09T04:17:22Z
Lists: pgsql-general
Christopher Browne wrote:
> A long time ago, in a galaxy far, far away, nolan@celery.tssi.com wrote:
> 
>>>MySQL can tell you from it's index because it doesn't care if it gives you the
>>>right number or not.
>>
>>Under what circumstances would MySQL give the wrong number?  
> 
> 
> It would give the wrong number under _every_ circumstance where there
> are uncommitted INSERTs or DELETEs.

Give them some credit. I just double checked:

Using mysql 4.0.14 + innodb and transactions,

select count(*) from foo;

does not count uncommited INSERTs.

Heck, even using myisam, mysql's count(*)'s still accurate, since all 
INSERTs, etc are autocommitted.

-- 
Linux homer 2.4.18-14 #1 Wed Sep 4 13:35:50 EDT 2002 i686 i686 i386 
GNU/Linux
  12:00pm  up 287 days,  3:33,  7 users,  load average: 6.93, 6.31, 6.16