function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
IWyattIWyatt 

Query Timeout: Attempting to Count # of Rows on Contact Object

Hey all,

 

The problem I'm facing is that an api query is timing out when all I want to do is count the number of records on the object. eg:

 

 

SELECT count() FROM contact Where email != ''

 

 

Purpose of the query is to count the number of rows on the contact object (with an email addy) in order to compare against a replicated set of records. We want to measure the % sync between SF and another system.

 

Any ideas of:

1) A method to prevent query timeout?

2) A method to count the # of records on the object without the query?

3) A work-around (creative suggestions on splitting the query up into smaller chunks?)

 

Thanks,

IW

Best Answer chosen by Admin (Salesforce Developers) 
AlwaysConfusedAlwaysConfused

 

 

Try adding an index to the email field (think you can do this in setup within SF).

If that fails, call SF support, we had this problem with a clients campaign members table (some 100 million or so records).

 

There are certain optimisations that can be done but it's mostly SF guys that will have to do it because it requires talking directly to the DB server something you can't do.

 

However, SF support is willing to look at these issues and help resolve them.