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

Chris Browne <cbbrowne@acm.org>

From: Christopher Browne <cbbrowne@acm.org>
To: pgsql-general@postgresql.org
Date: 2003-10-07T18:29:24Z
Lists: pgsql-general
A long time ago, in a galaxy far, far away, paul.serby@clockltd.com (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?

Look into the semantics of MVCC (MultiVersion Concurrency Control);
that (otherwise useful) feature prevents having any such "handy
record."
-- 
let name="cbbrowne" and tld="cbbrowne.com" in String.concat "@" [name;tld];;
http://www.ntlug.org/~cbbrowne/spreadsheets.html
Developmental Psychology
"Schoolyard behavior resembles adult primate behavior because "Ontogeny
Recapitulates Phylogeny" doesn't stop at birth."
-- Mark Miller