Count is slow on large database
Posted on 2003-12-01
As part of helping our users to change their application, we perform an outomatic database reorganisation for tables that have changed. For most this is a relatively quick operation. However we have found that upto a million records takes 'less than a second ' (sorry cannot be more definitive) but a table of 140 million records takes more than 3 minutes. At (less than 1 sec) at worst it should be no more than 2 minutes.
Any explanations or ideas to speed up?
The command is a simple: rec_count = count(*) from table
We could use a select rowcnt from system index tables, but then we are beholden to Microsoft to keep this feature, and it does not work for clustered index tables (or for other databases that we have to sometimes work with)