Batch Apex Explained
Batch Apex is designed for operations that need to process thousands or millions of records, volumes that would exceed governor limits in a single synchronous transaction. A batch class implements the Database.Batchable interface and defines three methods: start() returns a QueryLocator or Iterable that identifies the record set, execute() processes each batch of records (default 200 per batch, configurable up to 2,000), and finish() runs after all batches complete for cleanup or chaining.
Each execute() invocation gets its own set of governor limits, so a batch job processing 50,000 records in batches of 200 generates 250 separate transactions, each with fresh limits. Batch jobs run in the Flex Queue when five concurrent batches are already executing. The Database.executeBatch() method returns an AsyncApexJob ID for monitoring. Common use cases include data cleansing, archival, mass field updates, and nightly external system synchronization. Clientell AI can generate and schedule batch classes, and monitor their execution through your org's async job queue.