We are using the Un-managed package Survey force, which was enhanced based on our business requirement where it was completely stopped now. We could identify that the query limit was fetching more than 50000 records?

What could we do to optimize the query results?

  • Please take a moment to visit the help center, scroll through the tour, and read How to Ask. Without seeing your actual query or understanding the context in which you are using it, offering sound advice is nigh impossible.
    – Adrian Larson
    Commented May 9, 2017 at 13:41

1 Answer 1


You should look at using Batch Apex to accomplish your goals. You cannot retrieve more than 50,000 records your SOQL calls in a single context. However, with Batch Apex your logic will be processed in chunks of anywhere from 1 to 200 records in a batch.

You'd need to modify your business logic to take the batching into account if necessary.

Refer Apex documentation for Batch Jobs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .