Apex dataloder : 5 million records
Using batch apex: 50 milion records
Piece= batches: no.of: records/200..max 2000
Every batch apex contain 3 methods
Diff between dataloader and batch:
1. Dataloder handle 5mill and batch apex handle 50 million
2. Max batch size for dataloder is 200 and batch it is 2000
What is Batch Apex ?
Batch as the name suggests, is used when a large data (bulk) volume is involved and it has to be redundantly processed using a particular logic.
Implementing the Database.Batchable Interface: The Database.Batchable Interface contains three methods that must be implemented.
1. Start Method:
global (Database.QueryLocator | Iterable<sObject>)
start(Database.BatchableContextbc) {
}
The start method is called at the beginning of a batch Apex job. Use the start method to collect the records or objects to be passed to the interface method execute. This method returns either a Database.QueryLocator object or an iterable that contains the records or objects being passed into the job.
2. Execute Method:
global void execute(Database.BatchableContextBC, list<P>){
}
The execute method is called for each batch of records passed to the method. Use this method to do all required processing for each chunk of data.
3. Finish Method:
global void finish(Database.BatchableContextBC){
}
The finish method is called after all batches are processed. Use this method to send confirmation emails or execute post-processing operations.
No comments:
Post a Comment
Thank you.