Tim Ferguson said:
Opening a dynaset to count the records is incredibly wasteful of system
resources, as well as inconsiderate to other users who will find all the
records locked... If you have to use this method, at least use a Forward
Only Snapshot.
Then again, you just might not think it is sensible to cart an entire 350MB
table across the network when all you want to end up with is a single
integer (4 bytes). The COUNT(*) function, or its DCount() function
shortcut, allows the work to take place on the server and reduces
drastically the network traffic and resources in the workstation.
What's more, msoft make a few coy references to how SELECT COUNT(*) is
Rushmore optimized. Compared to SELECT COUNT(something_else), which isn't. I
believe they are referring to the following fact. The # of records in each
table, is stored & maintained in a data item in the table header (in the MDB
file). I believe that SELECT COUNT(*) will simply retrieve the data page
containing the table header, & get the count directly from there. No table
scan required, at all. Other methods (such as traversing a recordset of any
kind) will perform a full table scan.
Cheers,
TC