Sample code on a custom object, Asset__c, containing 78,000 rows:
Integer number1 = [SELECT count() FROM Asset__c ]; system.debug('Query Rows used by count():'+Limits.getQueryRows());
If i do this.. Since i have over 50,000 records a govenor limit is getting exceeded and it's throwing too many query rows : 50001 error. If run on a object with under 50,000 rows you'll still notice the debug output is much higher than the 1 row that's expected.
Please see this idea as well in SF.... "Count the SOQL count() query as a single row query"
Please promote this guys... This is really ridiculous!!!!
Is there any other alternative for querying the count????