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

From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: Paul Serby <paul(dot)serby(at)clockltd(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: "select count(*) from contacts" is too slow!
Date: 2003-10-07 18:33:34
Message-ID: Pine.LNX.4.21.0310071931360.5797-100000@ponder.fairway2k.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 7 Oct 2003, Paul Serby wrote:

> Why does '*select count(id) from "tblContacts"'* do a sequential scan
> when the field '*id*' is indexed using a btree?
>
> MySql simply looks at the index which is keeping a handy record of the
> number of rows.
>
> Can anybody explain how and why postgres does this query like it does?

It's a FAQ I believe.

MySQL can tell you from it's index because it doesn't care if it gives you the
right number or not.

--
Nigel Andrews

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rick Gigger 2003-10-07 18:43:21 Re: Possible bug on insert
Previous Message Christopher Browne 2003-10-07 18:29:24 Re: "select count(*) from contacts" is too slow!