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

How to handle query records more than 100000 in apex?

Hi all,



Here once again posting.


In API say PHP salesforce API we can handle huge data with querymore, querylocator. I have implemented. 


In Apex I have implemented standardsetController, paging. it is working fine for records upto 10000. I know its LIMIT and WELL KNOW ISSUE (as everyone taking about this ONLY).


I know there are more than 100000 records will return by query, I have to fetch and display with pagination. My concern is fetch and display.





Q. How to handle query records more than 100000 in apex?


Can anyone please answer this question so I can implement it?





Message Edited by Dowithforce on 10-29-2009 02:27 AM
Message Edited by Dowithforce on 10-29-2009 02:43 AM
Message Edited by Dowithforce on 10-29-2009 02:44 AM
you have multi-currency enabled for your live and sandbox orgs, but not dev. this isn't enabled by default, so you'd need to contact support to do so.
Check out this page on working with large data sets in apex:

Thanks for reply!


SOQL for loop is of that type but I don't want to do update, insert and delete operation (DML) though Ican I used it? please explain.



Message Edited by Dowithforce on 10-29-2009 01:01 PM
I'm interested in your use case of why you are trying to fetch 100,000 records. This is usually not a good practice for web applications in general and more specifically for apps due to the governor limits that are enforced.

Thanks for interest.


Let me clear the topic. I have to fetch leads but it is goining beyond gov. limits.


I have fine with 1000 records per query call paging with the setcontroller. But looking in to setcontroller


and 1000 records fetching query for each next button click. Any thought? 


Does this really work?

I tried and got following error where my query tries to fetch 0.1 Million records and update a field based on some condition.


System.Exception: Too many query rows: 501


for setcontroller it work for 10000 records.





I have a solid use case for wanting to COUNT more than 100,000. We need to know the total 'population' in order to correctly calculate the statistical sample size of records the user needs to select as part of an audit sample.


Because Salesforce considers COUNT and SELECT to be the same in term of resource usage, we're in quite a bit of trouble.


I'm also suprised (dissappointed) that, with the release of their new COUNT(Id) function in Spring 10, Salesforce haven't taken the opportunity to sort out the issue.