As the title says, I'm using a COUNT(id) query on some tables using the SOAP API. One of our tables is very large, and we're getting back QUERY_TIMEOUTs. Is there an easier way to figure out the size directly from the API? Assume I can't go into the front end at all.
I'm curious to know the requirement for total row count on an object with no limiting
WHERE clause. Can you elaborate on the use case?
A few common ways, the first which already gave you trouble:
Integer contactRows = [SELECT Count() FROM Contact];
You could also use a Summary Roll-up field on a parent object to aggregate the number of child records and then simply query this one field to get the total number of records. (sum a field on each record containing the number 1, 'the power of one')
https://dataloader.io/ ..This app has a count in last step of export and it tells how much data excatly is in Database .
Edit after rethinking with REST
Not sure about SOAP API but fot rest API we definately can achieve this easily
This API first attribute is totalsize and this will definately give the exact count .
eg("totalSize" : 37)
All you need is use a REST API call within the salesforce with token as userinfo.sessionId().