Re: "select count(*) from contacts" is too slow! - Mailing list pgsql-general

From Christopher Browne
Subject Re: "select count(*) from contacts" is too slow!
Date
Msg-id m3isn0aol7.fsf@wolfe.cbbrowne.com
Whole thread Raw
In response to "select count(*) from contacts" is too slow!  (Paul Serby <paul.serby@clockltd.com>)
List 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

pgsql-general by date:

Previous
From: "John Wells"
Date:
Subject: Humor me: Postgresql vs. MySql (esp. licensing)
Next
From: Christopher Browne
Date:
Subject: Re: "select count(*) from contacts" is too slow!