On 10/4/06, Drupal Indonesia support@drupal-id.com wrote:
currently, I solve this problem by take all row using DISTINCT then use "Drupal db count" to count the rows, but this is not efficient, because when my db contains 1.000 users then the results is 1.000 rows, what do I need only 1 row that contain "1000" value.
If you have a working query, don't worry about the future.
Donald Knuth: "Premature optimization is the root of all evil"
Wait until the query is a problem and then we can look into optimizing it. When you have 1000 users then this query will probably not be the bottleneck - something else will - so you should optimize the other thing.
Are you using this in a block? If so, use block_cache to cache the result.
Regards, Greg