+ Start a Discussion
QMEQME 

Bulk data processing

Background:

We load a lot of data (10,000) records into a custom object.

We have to process these 10,000 records and have the Apex scheduler kick of a Job (Apex Class) once a day.

We are receiving an error: System.Exception: Too many script statements: 200001 

 

We have optimized the code to use maps and lists for processing records to avoid DML governers limits. 

 

Questions:

  1. Is this the right approach to do bulk data processing?
  2. We are doing a lot of looping which we believe is causing this scripts statements error.  Can this error be avoided by processing smaller batch sizes (eg 500 records at a time) while still being within the same Apex Scheduled Job?  This way we avoid governors limits.  If so, how??
Best Answer chosen by Admin (Salesforce Developers) 
Anand@SAASAnand@SAAS
TRy reducing the number of records per batch. You can do this when you start the Batch. Refer to batch apex documentation here. Refer to the Database.executeBatch(...) method that takes an additional parameter for the number of records per batch.