Editorial question38.5K views2,665 votes0 answers525 following
AI-generatedBatchable Apex QueryLocator 50k Record Limit: Local Success vs Production Failure
Feature Overview The Database.getQueryLocator method in Batchable Apex is documented to cap each query at 50,000 records per execution. When the SOQL returns more than this threshold, the behavior differs between local scratch orgs and production environments. Observed Behavior In a scratch org with a modest data set, a batch that queries over 50,000 records