Governor limits cheat sheet
The per-transaction limits and habits from lesson DF1, on one page. Every line comes from the official sources linked below.
Per-transaction limits
| Limit | Sync | Async |
|---|---|---|
| SOQL queries issued | 100 | 200 |
| Records retrieved by SOQL | 50,000 | 50,000 |
| DML statements issued | 150 | 150 |
| Records processed by DML | 10,000 | 10,000 |
| CPU time on Salesforce servers | 10,000 ms | 60,000 ms |
Source: Apex Developer Guide: Execution Governors and Limits
Rules to remember
- Multitenancy means customers share computing power, data storage and core features, so Apex enforces governor limits. (Trailhead, What is Apex?)
- Limits are counted per transaction.
- A governor limit exception can’t be handled. Try/catch won’t save you; bulkify the code instead.
- DML on lists, not single records: collect records in a list inside the loop, then run one DML statement after it.
- SOQL outside loops: query once, for example with WHERE Id IN :Trigger.newMap.keySet(), and use a nested subquery for child rows.
- A SOQL for loop processes large result sets in batches of 200.
- In a query with parent-child subqueries, each parent-child relationship counts as an extra query.
Sources: Running Apex within Governor Execution Limits, Execution Governors and Limits, Trailhead: Write SOQL Queries
Exam traps
- “Wrap it in try/catch” is the wrong fix for a governor limit.
- 100 SOQL queries is the synchronous limit; 200 is asynchronous.
- 150 is the DML statement limit, not a SOQL limit.
Independent study material. Created by Nick Frates. Not affiliated with, sponsored by or endorsed by Salesforce, Inc. All questions are original and are not actual exam questions. Salesforce, Agentforce, Trailhead and other marks are trademarks of Salesforce, Inc., used only to identify the exam this material helps you study for.