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

From: Christopher Browne <cbbrowne(at)acm(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: "select count(*) from contacts" is too slow!
Date: 2003-10-07 18:29:24
Message-ID: m3isn0aol7.fsf@wolfe.cbbrowne.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

A long time ago, in a galaxy far, far away, paul(dot)serby(at)clockltd(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nigel J. Andrews 2003-10-07 18:33:34 Re: "select count(*) from contacts" is too slow!
Previous Message Paul Serby 2003-10-07 17:09:33 "select count(*) from contacts" is too slow!