Which per-transaction limits should you know by heart?
1What it is
The governor limits every synchronous and asynchronous Apex transaction runs inside.
2Why it matters
Almost every code question ends with "and what limit would this hit?". Knowing the numbers lets you answer at once - and design around them.
3Example
| Limit | Sync | Async |
|---|---|---|
| SOQL queries | 100 | 200 |
| Query rows | 50,000 | 50,000 |
| SOSL searches | 20 | 20 |
| DML statements | 150 | 150 |
| DML rows | 10,000 | 10,000 |
| CPU time | 10 s | 60 s |
| Heap | 6 MB | 12 MB |
| Callouts / total callout time | 100 / 120 s | 100 / 120 s |
| sendEmail calls | 10 | 10 |
| Trigger depth | 16 | 16 |
4In short - say this in the interview
100 SOQL (200 async), 50,000 query rows, 150 DML statements, 10,000 DML rows, 10 s CPU (60 s async), 6 MB heap (12 MB async), 100 callouts in 120 s, 10 sendEmail calls.
Mixing up DML statements (150) with DML rows (10,000). One update of a 10,000-record list is a single statement.
- Which limits are higher in async, and which are the same?
- How do you read the current usage? (The Limits class.)