Keep Running Totals in Salesforce Batch Apex with Database.Stateful
Learn how Database.Stateful preserves instance variables across Batch Apex chunks, with a worked counting example and heap limits to watch.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Learn how Database.Stateful preserves instance variables across Batch Apex chunks, with a worked counting example and heap limits to watch.
When you need to move millions of old Account records out of the active database, Batch Apex lets you break the work into chunks, stay under governor limits, and keep the org responsive. Learn how to write, run, and monitor a batch that archives inactive accounts in Salesforce.
Learn how to stay within Apex DML and heap limits by batching records, using savepoints, and choosing between Batch Apex and Queueable for large data jobs.
Learn how Salesforce Batch Apex splits large datasets into chunks, the best‑practice workflow, a hands‑on example, and key trade‑offs that can save you from hitting governor limits.
How Database.Batchable splits million-record jobs into governor-limit-isolated chunks: the start/execute/finish contract, QueryLocator vs Iterable, batch sizing, and partial-failure handling with a worked example.
Facing governor limits when updating thousands of records? Batch Apex splits work into 200-record chunks, keeping you within limits. This guide shows how to build, test, and monitor a batch that updates Account.Status, plus trade-offs you should know.
Goal: Process 200,000 records efficiently while staying within Salesforce governor limits. Constraints: Batch Apex can handle up to 50,000 records per batch and allows a configurable batchSize , but requires careful start/execute/finish handling to avoid CPU and heap limits. Queueable Apex limits each job to 200 records and the system to 50 queued jobs per 2
A Salesforce team needs to run a long data-synchronization job that may need to stop before completion when an external system signals a timeout or cancellation. Batch Apex naturally partitions work into scopes and provides a finish method for finalization, while Queueable Apex supports chaining to avoid a single transaction timeout. The unresolved decision