I need to get dynamic query result which returns rows more then 50K. Database.query() has 50K limit so I am trying to use Database.executeBatch(). On click of apex button, I want to display rows in apex:repeat. executeBatch returns rows in execute method which does not update apex:repeat control.
Following is the code:
//called by apex button to display result in apex:repeat control
public PageReference searchUsers(){
....
...
id batchInstance=Database.executeBatch(this,200);
...
return null;
}
global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator(Query + ' LIMIT 200');
}
global void execute(Database.BatchableContext BC,List<SObject> scope)
{
//Want to update apex:repeat control with the result
}
global void finish(Database.BatchableContext bc)
{
}
Attribution to: Sanjivani
Possible Suggestion/Solution #1
Normally, queries for a single Visualforce page request may not retrieve more than 50,000 rows. In read-only mode, this limit is relaxed to allow querying up to 1 million rows.
Set it on the page like this
<apex:page controller="SummaryStatsController" readOnly="true">
In addition to querying many more rows, the readOnly attribute also increases the maximum number of items in a collection that can be iterated over using components such as <apex:dataTable>
, <apex:dataList>
, and <apex:repeat>
. This limit increased from 1,000 items to 10,000. Here is a simple controller and page demonstrating this:
Attribution to: Doug B
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/33982