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

From Frank D. Engel, Jr.
Subject Re: [HACKERS] Much Ado About COUNT(*)
Date
Msg-id 2F4ADFB8-6653-11D9-9E6D-0050E410655F@fjrhome.net
Whole thread Raw
In response to Re: [HACKERS] Much Ado About COUNT(*)  (Wes <wespvp@syntegra.com>)
Responses Re: [HACKERS] Much Ado About COUNT(*)
Re: [HACKERS] Much Ado About COUNT(*)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This is probably stupid for some reason, but why not use a 64-bit
integer to track the number of records in the table? Increment when
adding records, decrement when deleting them... then COUNT(*) could
just return that in cases where a query is known to be looking at all
of the records?

On Jan 14, 2005, at 12:04 PM, Wes wrote:

> 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.
>>
>> It doesn't have to read and ignore the dead records since they're in a
>> separate place (but on the other hand it sometimes have to go read
>> that
>> separate place when it sees records that were committed after your
>> transaction).
>>
>> It can also do index-only scans, which often helps, but it's still not
>> instantaneous.
>
> 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.
>
> Wes
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>
>
- -----------------------------------------------------------
Frank D. Engel, Jr.  <fde101@fjrhome.net>

$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten
Son, that whosoever believeth in him should not perish, but have
everlasting life.
$
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iD8DBQFB6AO47aqtWrR9cZoRAs7UAKCQL3VnSu3770AyFoKW/X7xR7REfQCeK1Ud
M/sIP2jY+6LIfOcrJM5vvUQ=
=Qlbi
-----END PGP SIGNATURE-----



___________________________________________________________
$0 Web Hosting with up to 120MB web space, 1000 MB Transfer
10 Personalized POP and Web E-mail Accounts, and much more.
Signup at www.doteasy.com


pgsql-general by date:

Previous
From: Greg Stark
Date:
Subject: Re: [HACKERS] Much Ado About COUNT(*)
Next
From: Michael Fuhr
Date:
Subject: Re: OID Usage