Re: [HACKERS] Much Ado About COUNT(*) - Mailing list pgsql-general

From Greg Stark
Subject Re: [HACKERS] Much Ado About COUNT(*)
Date
Msg-id 87d5w8udrw.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: [HACKERS] Much Ado About COUNT(*)  (Wes <wespvp@syntegra.com>)
List pgsql-general
Wes <wespvp@syntegra.com> writes:

> On 1/13/05 6:44 PM, "Greg Stark" <gsstark@mit.edu> wrote:
>
> > That's simply false. Oracle does indeed have to count the records one by one.

> Ok, I stand corrected - I was given some wrong information.  However, my
> experience has been that count(*) on Oracle is a whole lot faster than
> PostgreSQL - what appeared instantaneous on Oracle took some time on
> PostgreSQL.  That was one of the first things I noticed when moving a
> database application to PostgreSQL.  I've since disposed of the Oracle
> database, so can't go back and retest.

If it was instantaneous then the data must have all been in cache. A lot of
Oracle kudos really come down to the fact that Oracle is often run on beefier
machines than others.

But if it was merely 2x as fast or so, more if the table was really wide, then
it could have just been because of the fast index-only scan.

If it was more than 2-4x as fast for a narrow table and you don't think the
whole thing was in cache then I would start to wonder about whether your
postgres table suffered from bloat from not having vacuum run frequently
enough or having the fsm settings too low.

--
greg

pgsql-general by date:

Previous
From: Wes
Date:
Subject: Re: [HACKERS] Much Ado About COUNT(*)
Next
From: "Frank D. Engel, Jr."
Date:
Subject: Re: [HACKERS] Much Ado About COUNT(*)