Naveen Goyal
Naveen Goyal

Reputation: 11

accessing large number of records in SOQL

In salesforce, I am having a custom object and there can be million of records in that object in future. I am developing a dashboard using apex and visualforce so i need to access all the records at one time in single query. The query is: [select count(custom_cases__C), status__c from custom_case__C group by status__c]

So it is accessing all the records at one time and exceeding governer limits.

What can I do to achieve this?

please provide me with the solution and if possible with an example because I am new to salesforce.

Upvotes: 1

Views: 2709

Answers (2)

Shailesh Deshpande
Shailesh Deshpande

Reputation: 166

You can run your page in read only mode. There are certain restrictions on this also. You might want to take a look at the below link:

http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_readonly_context.htm

Upvotes: 1

pjcarly
pjcarly

Reputation: 426

It is a shame that salesforce counts an aggregate function not as 1 result, but as the amount of rows aggregated. Which means that if you have over 50000 results, you'll get an error (SOBject query row exceeded, something in that line)

There is an Idea for that, please upvote!

The only workable solution I see for you at the moment is (and also the solution I use myself) is program and schedule a Apex Batch Job to run, and save the results in a new custom object. Then use that custom object as the source for your dashboard.

Upvotes: 3

Related Questions