+ Start a Discussion
Brian Marks 2Brian Marks 2 

Can a schedulable job process 10000 records

I neeed to build a process to complete the following:

Read all records from an Object  (10000+ records)
Apply criteria to group the records by user and accumulate count fields
Insert the resulting records (User, Count) 

I dont believe I can use Batchable as I need to read all of the records before building the output records.
If this is possible, would I likely hit processing limits?

I was able to build this logic using a Java program and API calls, but have been asked if possible to build Salesforce job to do the same?
 
kaustav goswamikaustav goswami
Your scenario seems to be one where you would need to use State in a batch class.

Use a batch apex class. This is what will allow you to process large volumes of data.
In the batch class along with the Database.Batchable interface you will have to use Database.Stateful interface. Using that all the instance variables will retain their values within states.

Please refer to this page - under the sub-heading - Using State in Batch Apex.

You will be able to keep the aggregate totals and then do an update.

Thanks,
Kaustav