Count large number of records (more than 50,000)

In a Salesforce org that has more than 50,000 records of an object, the following simple count() query will still hit the Salesforce governor limit: “System.LimitException: Too many query rows: 50001” Even though it seems that the count function does not need to traverse the whole Contact table, it still does, for specific reasons like …