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
shalini sharma 24shalini sharma 24 

how to query more than 50000 records in apex and bind it in vf page? As there is a governor limit of 50000 records retreived by SOQL query, so how to achieve this?

I want to display all the records returned by SOQL query in a VF Page through PageBlockTable and Pagination. But the tweak is that retrieved records are more than 50k and there is limit of 50K records . This has to be done in a synchronous way.
Balayesu ChilakalapudiBalayesu Chilakalapudi
You can use Batch apex for fetching records more than 10k,

Create a global list in batch class and add all records returned by your batches
Get the list in your vf controller like this,
//Batch class:

class YourBatch{
 public List<sObject> vflist=new List<sobject>();
  //get all records

//VF controller class
class YourVFController{
   public List<sObject> listtoReturn{get;set;}
        YourBatch b=new YourBatch();

//VF Page
   //iterate listtoReturn on your pageblock table