{"id":1620,"date":"2026-09-10T13:00:00","date_gmt":"2026-09-10T07:30:00","guid":{"rendered":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/"},"modified":"2026-09-10T13:00:00","modified_gmt":"2026-09-10T07:30:00","slug":"batch-apex-start-execute-finish","status":"publish","type":"post","link":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/","title":{"rendered":"Batch Apex: start, execute and finish Explained with Examples"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Batch Apex processes very large numbers of records by splitting them into small chunks and running each chunk in its own transaction. One transaction can query only 50,000 rows, but a batch job can work through millions. So it is the right tool for nightly fee updates, data clean-ups and archiving.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, you will learn the three methods of a batch class, how batch size works, how Database.Stateful keeps totals, and how to start, monitor and test a job. It builds on <a href=\"https:\/\/swapnilzambare.com\/blog\/asynchronous-apex-overview\/\">Asynchronous Apex<\/a>, <a href=\"https:\/\/swapnilzambare.com\/blog\/queueable-apex-chaining-finalizers\/\">Queueable Apex<\/a> and <a href=\"https:\/\/swapnilzambare.com\/blog\/apex-bulkification-best-practices\/\">Apex bulkification<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Batch Apex?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Batch Apex is an Apex class that implements the Database.Batchable interface with three methods: start, execute and finish. start collects the records, execute processes one chunk at a time, and finish runs once at the end. Salesforce manages the chunks for you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of moving a library to a new building. Nobody carries 50,000 books at once. You list every shelf, move one box of books per trip, and do a final check when the last box arrives. start is the list, execute is each trip, and finish is the final check.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Batch Apex Matters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Large data jobs break normal limits. Here is why Batch Apex matters at Bright Path Tutors.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, raising fees by 5% touches every one of 300,000 courses.<\/li>\n\n<li>Also, closing old enrolments each term involves millions of rows.<\/li>\n\n<li>Next, a data clean-up must not lock the whole org for minutes.<\/li>\n\n<li>Each chunk gets fresh governor limits, so big jobs stay safe.<\/li>\n\n<li>Finally, one bad record fails only its own chunk, not the whole job.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">So whenever data is larger than one transaction can handle, Batch Apex is the answer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Batch Apex Works<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Batch Apex follows a fixed flow. First, Database.executeBatch queues the job and returns a job Id. Next, Salesforce calls start once, which returns a QueryLocator or an Iterable of records. Then Salesforce splits the records into chunks of the batch size, 200 by default. After that, it calls execute once for each chunk, each in a new transaction with fresh limits. Finally, after the last chunk, it calls finish once, where you can send a summary or start another job.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-1-1024x640.png\" alt=\"Batch Apex diagram showing queue, start, chunks, execute, repeat and finish\" class=\"wp-image-1618\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-1-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-1-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-1-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-1-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-1-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">How a batch job splits records into chunks.<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">The start Method<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">start returns the records to process. A Database.QueryLocator can return up to 50 million records. An Iterable is useful for custom logic but is limited by normal query row limits.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The execute Method<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">execute receives one chunk, called the scope, as a List&lt;sObject&gt;. Write it in a bulk-safe way, with one query and one DML per object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The finish Method<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">finish runs once after all chunks. Use it for summary emails, logs or starting the next batch.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Batch Size<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The second argument of Database.executeBatch sets the scope size, from 1 to 2,000, with 200 as the default. Use smaller sizes when each record needs heavy work or callouts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Database.Stateful<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Batch classes normally forget member variable values between chunks. Implement Database.Stateful when you need running totals, such as a count of updated records.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Callouts<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Implement Database.AllowsCallouts when execute or finish calls another system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Batch Apex Limits<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below lists the limits that shape batch design.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Limit<\/th><th>Value<\/th><\/tr><\/thead><tbody><tr><td>Records from a QueryLocator<\/td><td>Up to 50 million<\/td><\/tr><tr><td>Scope size<\/td><td>1 to 2,000, default 200<\/td><\/tr><tr><td>Batch jobs queued or active at once<\/td><td>5<\/td><\/tr><tr><td>Jobs waiting in the flex queue<\/td><td>Up to 100<\/td><\/tr><tr><td>execute calls in an Apex test<\/td><td>1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Batch Apex vs Queueable Apex<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The table below compares the two most used async tools.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Feature<\/th><th>Batch Apex<\/th><th>Queueable Apex<\/th><\/tr><\/thead><tbody><tr><td>Data size<\/td><td>Millions of records<\/td><td>Within normal async limits<\/td><\/tr><tr><td>Methods<\/td><td>start, execute, finish<\/td><td>execute<\/td><\/tr><tr><td>Fresh limits per chunk<\/td><td>Yes<\/td><td>No, one transaction per job<\/td><\/tr><tr><td>Keeping totals<\/td><td>Database.Stateful<\/td><td>Member variables in one job<\/td><\/tr><tr><td>Best for<\/td><td>Huge record sets<\/td><td>Medium jobs and step-by-step work<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When to use which comes down to size. If the work fits in one transaction, use Queueable. If it needs many chunks, use Batch Apex.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-2-1024x640.png\" alt=\"Batch Apex diagram comparing Batch Apex and Queueable Apex\" class=\"wp-image-1619\" srcset=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-2-1024x640.png 1024w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-2-300x188.png 300w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-2-768x480.png 768w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-2-1536x960.png 1536w, https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-diagram-2-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Batch Apex vs Queueable Apex.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">A Real Batch Apex Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s build Batch Apex for a yearly 5% fee increase at Bright Path Tutors, with a count of updated courses.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: The Batch Class<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>public with sharing class CourseFeeIncreaseBatch\n        implements Database.Batchable&lt;SObject&gt;, Database.Stateful {\n\n    private Integer updated = 0;   \/\/ kept across chunks by Database.Stateful\n\n    public Database.QueryLocator start(Database.BatchableContext bc) {\n        return Database.getQueryLocator(\n            'SELECT Id, Fee__c FROM Course__c WHERE Fee__c != null');\n    }\n\n    public void execute(Database.BatchableContext bc, List&lt;Course__c&gt; scope) {\n        for (Course__c c : scope) {\n            c.Fee__c = (c.Fee__c * 1.05).setScale(2);\n        }\n        update scope;\n        updated += scope.size();\n    }\n\n    public void finish(Database.BatchableContext bc) {\n        System.debug('Fee increase done. Courses updated: ' + updated);\n    }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">start returns every course with a fee. execute raises each fee by 5% and updates the chunk with one DML statement. Because the class is stateful, updated keeps growing across chunks, and finish prints the total.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Start the Job<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>Id jobId = Database.executeBatch(new CourseFeeIncreaseBatch(), 200);\nSystem.debug('Batch queued: ' + jobId);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This queues the job with chunks of 200 courses. You can run it from anonymous Apex, a button, or Scheduled Apex, which is the next post.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Monitor Progress<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT Status, JobItemsProcessed, TotalJobItems, NumberOfErrors\nFROM AsyncApexJob\nWHERE Id = :jobId<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here is what the query returns while the job runs on 300,000 courses.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Status: Processing   JobItemsProcessed: 640   TotalJobItems: 1500   NumberOfErrors: 0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">TotalJobItems is the number of chunks, 1,500 here. You can also watch progress in Setup &gt; Apex Jobs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing Batch Apex<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A test can run only one execute call. So insert no more records than the batch size, call Database.executeBatch between Test.startTest and Test.stopTest, then assert the results after stopTest.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Batch Apex<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Writing SOQL or DML inside loops in execute.<\/li>\n\n<li>Using a huge scope size with callouts or heavy logic.<\/li>\n\n<li>Forgetting Database.Stateful, then wondering why totals reset.<\/li>\n\n<li>Starting many batch jobs at once and filling the flex queue.<\/li>\n\n<li>Inserting more records than one batch in a test.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Batch Apex<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Keep execute bulk-safe, with one query and one DML per object.<\/li>\n\n<li>Choose the scope size based on the work per record.<\/li>\n\n<li>Use Database.Stateful only for the values you truly need.<\/li>\n\n<li>Log errors and send a summary in finish.<\/li>\n\n<li>Schedule big jobs for quiet hours.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Change the batch so it skips courses with Is_Online__c set to true, and count skipped courses separately. Hint: either add a WHERE filter in start, or count inside execute with a second stateful variable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Most Asked Interview Questions on Batch Apex<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Batch Apex is one of the most asked developer topics. Here are the 21 questions asked most about Batch Apex.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Questions on Batch Apex<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1: What is Batch Apex?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An Apex class that processes large record sets in chunks, using start, execute and finish.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2: Which interface does a batch class implement?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Database.Batchable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3: What does start return?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A Database.QueryLocator or an Iterable of records.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4: What is the default batch size?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">200 records per chunk.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5: What is the maximum batch size?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2,000 records per chunk.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6: How do you start a batch job?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Call Database.executeBatch with an instance of the class and an optional scope size.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7: How many records can a QueryLocator return?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Up to 50 million.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Code and Scenario Questions on Batch Apex<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8: Does each execute call get fresh governor limits?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. Each chunk runs in its own transaction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9: How do you keep a running total across chunks?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Implement Database.Stateful and store the total in a member variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10: How do you make callouts in a batch?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Implement Database.AllowsCallouts and use a small scope size.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q11: How many batch jobs can be active at once?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Five, with up to 100 more waiting in the flex queue.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q12: What happens if one chunk fails?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Only that chunk rolls back. Other chunks still commit.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q13: How do you monitor a batch job?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Query AsyncApexJob or check Setup &gt; Apex Jobs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q14: How do you test a batch class?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Insert up to one batch of records, run it between startTest and stopTest, then assert.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Advanced Questions on Batch Apex<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q15: When would you use an Iterable in start?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When records come from custom logic or several sources instead of one query.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q16: How do you chain batch jobs?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Call Database.executeBatch for the next job inside finish.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q17: Can you call a future method from a batch?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">No. Use Queueable or another batch instead.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q18: What is the flex queue?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A holding area for up to 100 batch jobs waiting to run, which admins can reorder.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q19: Why might you choose a smaller scope size?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To stay within limits when each record needs heavy queries, DML or callouts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q20: How do you handle partial failures inside execute?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use Database methods with allOrNone set to false and log failed rows.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q21: How do you schedule a batch job?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Call it from a Schedulable class, or use System.scheduleBatch.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexcode.meta\/apexcode\/apex_batch_interface.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Using Batch Apex (Apex Developer Guide)<\/a><\/li>\n\n<li><a href=\"https:\/\/trailhead.salesforce.com\/content\/learn\/modules\/asynchronous_apex\/async_apex_batch\" target=\"_blank\" rel=\"noopener noreferrer\">Use Batch Apex (Trailhead)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Batch Apex processes huge record sets in chunks.<\/li>\n\n<li>start collects records, execute handles each chunk, finish runs once.<\/li>\n\n<li>Each chunk gets fresh governor limits.<\/li>\n\n<li>Database.Stateful keeps totals across chunks.<\/li>\n\n<li>Tests can run only one execute call.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Batch jobs often run at night on a timetable. Next, read our guide to <a href=\"https:\/\/swapnilzambare.com\/blog\/scheduled-apex-cron-expressions\/\">Scheduled Apex and cron expressions<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Batch Apex processes very large numbers of records by splitting them into small chunks and running each chunk in its own transaction. One transaction&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1617,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[8,96],"tags":[68,98,112,109,91,7,97],"swapz_series":[],"class_list":["post-1620","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-salesforce","category-salesforce-developer","tag-advanced","tag-apex","tag-async-apex","tag-governor-limits","tag-interview-questions","tag-salesforce","tag-salesforce-developer"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Batch Apex: start, execute and finish Explained<\/title>\n<meta name=\"description\" content=\"Batch Apex explained simply: start, execute and finish, QueryLocator, batch size, Database.Stateful, flex queue, monitoring, testing and 21 interview Q&amp;A.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Batch Apex: start, execute and finish Explained\" \/>\n<meta property=\"og:description\" content=\"Batch Apex explained simply: start, execute and finish, QueryLocator, batch size, Database.Stateful, flex queue, monitoring, testing and 21 interview Q&amp;A.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/\" \/>\n<meta property=\"og:site_name\" content=\"Swapnil Zambare - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-10T07:30:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Swapnil Zambare\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Swapnil Zambare\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/\"},\"author\":{\"name\":\"Swapnil Zambare\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\"},\"headline\":\"Batch Apex: start, execute and finish Explained with Examples\",\"datePublished\":\"2026-09-10T07:30:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/\"},\"wordCount\":1446,\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/batch-apex-start-execute-finish-featured.png\",\"keywords\":[\"Advanced\",\"Apex\",\"Async Apex\",\"Governor Limits\",\"Interview Questions\",\"Salesforce\",\"Salesforce Developer\"],\"articleSection\":[\"Salesforce\",\"Salesforce Developer\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/\",\"name\":\"Batch Apex: start, execute and finish Explained\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/batch-apex-start-execute-finish-featured.png\",\"datePublished\":\"2026-09-10T07:30:00+00:00\",\"description\":\"Batch Apex explained simply: start, execute and finish, QueryLocator, batch size, Database.Stateful, flex queue, monitoring, testing and 21 interview Q&A.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/#primaryimage\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/batch-apex-start-execute-finish-featured.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/batch-apex-start-execute-finish-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Batch Apex featured image: title card with an Apex code example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/batch-apex-start-execute-finish\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Batch Apex: start, execute and finish Explained with Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"name\":\"Swapnil Zambare - Blog\",\"description\":\"Salesforce &amp; Tech Guides\",\"publisher\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#organization\",\"name\":\"Swapnil Zambare - Blog\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"contentUrl\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/site-icon-512.png\",\"width\":512,\"height\":512,\"caption\":\"Swapnil Zambare - Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/theSwapnilZambare\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/#\\\/schema\\\/person\\\/922ac0131aaa7088c78c2cb1700e0c9a\",\"name\":\"Swapnil Zambare\",\"sameAs\":[\"https:\\\/\\\/swapnilzambare.com\\\/blog\"],\"url\":\"https:\\\/\\\/swapnilzambare.com\\\/blog\\\/author\\\/swapnil-zambare\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Batch Apex: start, execute and finish Explained","description":"Batch Apex explained simply: start, execute and finish, QueryLocator, batch size, Database.Stateful, flex queue, monitoring, testing and 21 interview Q&A.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/","og_locale":"en_US","og_type":"article","og_title":"Batch Apex: start, execute and finish Explained","og_description":"Batch Apex explained simply: start, execute and finish, QueryLocator, batch size, Database.Stateful, flex queue, monitoring, testing and 21 interview Q&A.","og_url":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/","og_site_name":"Swapnil Zambare - Blog","article_published_time":"2026-09-10T07:30:00+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-featured.png","type":"image\/png"}],"author":"Swapnil Zambare","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Swapnil Zambare","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/#article","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/"},"author":{"name":"Swapnil Zambare","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a"},"headline":"Batch Apex: start, execute and finish Explained with Examples","datePublished":"2026-09-10T07:30:00+00:00","mainEntityOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/"},"wordCount":1446,"publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-featured.png","keywords":["Advanced","Apex","Async Apex","Governor Limits","Interview Questions","Salesforce","Salesforce Developer"],"articleSection":["Salesforce","Salesforce Developer"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/","url":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/","name":"Batch Apex: start, execute and finish Explained","isPartOf":{"@id":"https:\/\/swapnilzambare.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/#primaryimage"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/#primaryimage"},"thumbnailUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-featured.png","datePublished":"2026-09-10T07:30:00+00:00","description":"Batch Apex explained simply: start, execute and finish, QueryLocator, batch size, Database.Stateful, flex queue, monitoring, testing and 21 interview Q&A.","breadcrumb":{"@id":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/#primaryimage","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-featured.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/11\/batch-apex-start-execute-finish-featured.png","width":2400,"height":1260,"caption":"Batch Apex featured image: title card with an Apex code example"},{"@type":"BreadcrumbList","@id":"https:\/\/swapnilzambare.com\/blog\/batch-apex-start-execute-finish\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/swapnilzambare.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Batch Apex: start, execute and finish Explained with Examples"}]},{"@type":"WebSite","@id":"https:\/\/swapnilzambare.com\/blog\/#website","url":"https:\/\/swapnilzambare.com\/blog\/","name":"Swapnil Zambare - Blog","description":"Salesforce &amp; Tech Guides","publisher":{"@id":"https:\/\/swapnilzambare.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/swapnilzambare.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/swapnilzambare.com\/blog\/#organization","name":"Swapnil Zambare - Blog","url":"https:\/\/swapnilzambare.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","contentUrl":"https:\/\/swapnilzambare.com\/blog\/wp-content\/uploads\/2026\/09\/site-icon-512.png","width":512,"height":512,"caption":"Swapnil Zambare - Blog"},"image":{"@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.linkedin.com\/in\/theSwapnilZambare"]},{"@type":"Person","@id":"https:\/\/swapnilzambare.com\/blog\/#\/schema\/person\/922ac0131aaa7088c78c2cb1700e0c9a","name":"Swapnil Zambare","sameAs":["https:\/\/swapnilzambare.com\/blog"],"url":"https:\/\/swapnilzambare.com\/blog\/author\/swapnil-zambare\/"}]}},"_links":{"self":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/comments?post=1620"}],"version-history":[{"count":0,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/posts\/1620\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media\/1617"}],"wp:attachment":[{"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/media?parent=1620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/categories?post=1620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/tags?post=1620"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/swapnilzambare.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=1620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}