Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
    
Is that your full SOQL query? Just Count(Id) FROM [table]? –  Mike Chale Dec 27 '12 at 20:51
    
Yes, I'm looking for the total row count of the table, straight from the SOAP API (we're using the Beatbox library), so Select Count(id) from [Table]. –  chowes Jan 2 '13 at 18:31
add comment

2 Answers 2

up vote 1 down vote accepted

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')

share|improve this answer
    
The use case is strictly to find the number of rows in a table. The tables are not owned by us, but rather one of our clients. We periodically download this data (mostly just new rows, but occasionally full pulls of this data). The problem is when we try to pull the full data, we run into issues when there are a large # of rows. We'd like to know WHEN we're going to hit these issues by getting a row count in advance. –  chowes Jan 2 '13 at 18:37
add comment

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

/services/data/v26.0/query/?q=Select+id+From+Account

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().

share|improve this answer
    
This is interesting.. apparently the API is coming soon, so I will have to wait on that. –  chowes Jan 2 '13 at 18:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.