db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Pendleton <bpendle...@amberpoint.com>
Subject Re: COUNT() optimisation
Date Sun, 10 Feb 2008 23:39:33 GMT
> I don't suppose there is some advanced way to get an approximate count.  When 
> the number of items is so large it seems a little pointless to get an 
> accurate count anyway; within 1% would be acceptable if there were a way to 
> get it quickly.

This seems like something you could build yourself:
  - As a background task, periodically run the queries to compute the
    counts of interest, and store those count results in a special
    "pre-computed counts" table.
  - In places in your application where you are willing to tolerate
    an approximate count, fetch the pre-computed count from your
    special table.
  - Vary the period of re-computing the counts to control how accurate
    (that is, how recently re-computed) your counts are. The more often
    you re-compute the counts, the more accurate they will be, but the
    higher the overhead you'll see from the re-compute background task.


View raw message