Re: *sigh* - Mailing list pgsql-hackers

From Christoph Haller
Subject Re: *sigh*
Date
Msg-id 200312031204.NAA23410@rodos
Whole thread Raw
In response to *sigh*  (Thomas Zehetbauer <thomasz@hostmaster.org>)
List pgsql-hackers
Fairly good idea IMHO, especially considering Christopher's point 
about the unlikeliness of needing an exact count anyway. 

Regards, Christoph 

> 
> How about:
> 
> Implement a function "estimated_count" that can be used instead of 
> "count". It could use something like the algorithm in 
> src/backend/commands/analyze.c to get a reasonably accurate psuedo count 
> quickly.
> 
> The advantage of this approach is that "count" still means (exact)count 
> (for your xact snapshot anyway). Then the situation becomes:
> 
> Want a fast count? - use estimated_count(*)
> Want an exact count - use count(*)
> 
> regards
> 
> Mark
> 
> Christopher Browne wrote:
> 
> >For a small table, it will be cheaper to walk through and calculate
> >count(*) directly from the tuples themselves.
> >
> >The situation where it may be worthwhile to do this is a table which
> >is rather large (thus count(*) is expensive) where there is some
> >special reason to truly care how many rows there are in the table.
> >For _most_ tables, it seems unlikely that this will be true.  For
> >_most_ tables, it is absolutely not worth the cost of tracking the
> >information.
> >  
> >


pgsql-hackers by date:

Previous
From: Mark Kirkwood
Date:
Subject: Re: *sigh*
Next
From: "E.Rodichev"
Date:
Subject: Re: Encoding problem with 7.4