Suggested answer

Standard SOQL: List<Account> accts = [SELECT Id FROM Account]; — all results are loaded into heap at once. 50,000 row limit. Risk: heap overflow with large result sets. SOQL For Loop: for (Account a : [SELECT Id FROM Account]) {...} — processes records one at a time; Salesforce fetches them in batches internally. Reduces heap usage. Still subject to the 50,000 row limit. Batched SOQL For Loop: for (List<Account> batch : [SELECT Id FROM Account]) {...} — processes 200 records per iteration (the most efficient pattern for Batch Apex context). For more than 50,000 records, use Batch Apex with a QueryLocator in start() — this can handle up to 50 million rows. QueryLocator bypasses the standard 50,000 row SOQL limit.

Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.

Community comments (0)

No comments yet.

Sign in or create a free account to add a comment. Comments are moderated before they appear.

Plain text only, 3–2000 characters. A moderator reviews every comment before it is published.