Free sample lesson from the Platform Developer Cert Lab. The full course has 21 lessons and 370 practice questions.
Unlock every sectionDF1: Multitenancy and governor limits
You’ll be able to: explain why a multitenant platform enforces governor limits, recall the per-transaction limits the exam leans on, and spot code that will hit them.
Per-transaction limits: which one bites when
| Limit | Synchronous | Asynchronous | Typical cause |
|---|---|---|---|
| SOQL queries issued | 100 | 200 | A query inside a for loop |
| Records retrieved by SOQL | 50,000 | 50,000 | Querying a whole large object |
| DML statements issued | 150 | 150 | An insert or update inside a loop |
| Records processed by DML | 10,000 | 10,000 | One huge DML list |
| CPU time on Salesforce servers | 10,000 ms | 60,000 ms | Heavy loops and processing |
Multitenancy in one sentence
Salesforce is like an apartment building: your company has its own space, but you share computing power, data storage and core features with every other customer. That sharing is multitenancy, and it’s also why everyone gets the same upgrades without installing anything.
Why limits exist
Apex is multitenant aware. Because it runs on shared resources, the Apex runtime engine strictly enforces governor limits so runaway code can’t monopolize them. Limits are counted per transaction. When code exceeds one, the governor throws a runtime exception that can’t be handled: no try/catch saves you. The only fix is code that stays inside the limits.
The two habits that prevent most limit errors
1. DML on lists, not single records. The Apex Developer Guide shows a loop that updates one line item per iteration: with more than 150 items, the 151st update throws. The fix collects records in a list and updates once:
List<Line_Item__c> updatedList = new List<Line_Item__c>();
for (Line_Item__c li : liList) {
if (li.Units_Sold__c > 10) {
li.Description__c = 'New description';
updatedList.add(li);
}
}
// One DML call for the entire list of line items
update as user updatedList;
2. SOQL outside loops. A query inside a loop over Trigger.new runs once per record, so more than 100 records breaks the 100-query limit. Query once with WHERE Id IN :Trigger.newMap.keySet() and use a nested subquery for child rows. To handle large result sets, a SOQL for loop processes records in batches of 200.
One more detail: in a query with parent-child subqueries, each parent-child relationship counts as an extra query.
Exam trap
“Wrap it in try/catch” is the wrong fix for a governor limit. Limit exceptions can’t be handled; you have to bulkify the code. Also watch the sync vs async numbers: 100 SOQL queries is the synchronous limit, 200 is asynchronous.
Predict, then reveal
A trigger loops over Trigger.new and runs one SOQL query per record. A data load inserts 150 records in one transaction. What happens?
Show the answer
It fails. The 101st query exceeds the synchronous limit of 100 SOQL queries, and the exception can’t be caught.
Try it
- In your Developer Edition org, open the Developer Console and choose Debug > Open Execute Anonymous Window.
- Paste a loop that builds a
List<Account>of 3 new accounts and callsinsertonce after the loop, then click Execute. - Open the Query Editor tab and run
SELECT Name FROM Account ORDER BY CreatedDate DESC LIMIT 3. Result: your 3 accounts appear in Query Results, saved with one DML statement.
Practice questions
Ten exam-style questions on this lesson. Answer each one before you open it.
Question 1. A trigger runs one SOQL query for each record in Trigger.new. What’s the largest synchronous batch it can handle before failing on queries alone?
- A. 150 records
- B. 100 records
- C. 200 records
- D. 50,000 records in a single run
Show the answer and explanation
Answer: B. The synchronous limit is 100 SOQL queries per transaction, so the 101st record’s query fails.
150 is the DML statement limit, 200 is the asynchronous SOQL limit, and 50,000 is the row limit.
Question 2. Why does the Apex runtime enforce governor limits?
- A. Resources are shared in a multitenant platform
- B. Each org runs on its own dedicated server, so limits protect hardware
- C. Limits only apply to managed packages
- D. Limits keep test classes fast to run
Show the answer and explanation
Answer: A. Limits stop runaway code from monopolizing shared resources.
Orgs share resources, and limits apply to all Apex, not only packages or tests.
Question 3. A developer wraps a loop of single-record updates in try/catch to recover from a governor limit error. Will this work?
- A. Only when the class runs without sharing
- B. Yes, if the catch block retries the update
- C. No, limit exceptions can’t be handled
- D. Yes, but only in asynchronous Apex
Show the answer and explanation
Answer: C. Exceeding a governor limit throws a runtime exception that can’t be handled.
Retrying, async context or sharing settings don’t make it catchable.
Question 4. Which two changes reduce the chance of hitting the DML statement limit? (Choose 2)
- A. Call update once on the list after the loop
- B. Split the code across two separate classes in the same transaction
- C. Call update on each record inside the loop
- D. Add records to a list inside the loop
Show the answer and explanation
Answer: A, D. Collect records in a list, then run one DML statement on the list.
DML inside the loop uses one statement per record, and splitting classes doesn’t reset the per-transaction count.
Question 5. What’s the synchronous CPU time limit per Apex transaction?
- A. 60,000 milliseconds
- B. 10,000 milliseconds
- C. 10 minutes, the same as maximum execution time
- D. 120 seconds
Show the answer and explanation
Answer: B. Synchronous CPU time is 10,000 ms; asynchronous is 60,000 ms.
60,000 ms is async, 120 seconds is the callout timeout total, and 10 minutes is maximum execution time.
Question 6. A batch of 151 records reaches code that runs one update statement per record. Which limit is hit?
- A. The 50,000 row retrieval limit
- B. The 10,000 DML row limit
- C. The 100 SOQL query limit
- D. The 150 DML statement limit
Show the answer and explanation
Answer: D. The 151st update statement exceeds the limit of 150 DML statements.
No queries are involved, and the row counts are far below those limits.
Question 7. A query returns a very large number of records. Which approach does the Apex guide recommend to process them in chunks?
- A. One DML statement per record
- B. A SOQL for loop
- C. A query inside each loop iteration
- D. Catching the limit exception and continuing
Show the answer and explanation
Answer: B. A SOQL for loop works through results in batches of 200.
Queries in loops and per-record DML add load, and limit exceptions can’t be caught.
Question 8. Which two statements about multitenancy are true? (Choose 2)
- A. Each customer installs its own database server
- B. Large customers get faster core features than small ones
- C. Upgrades arrive without customers installing them
- D. Customers share computing power and storage
Show the answer and explanation
Answer: C, D. Multitenancy means shared resources and seamless upgrades for everyone.
There’s no customer-installed server, and everyone gets the same core features.
Question 9. How is a parent-child subquery counted against the SOQL query limit?
- A. Each parent-child relationship counts as an extra query
- B. It counts only when the query runs in asynchronous Apex code
- C. Subqueries never count toward any limit
- D. The whole query counts as zero queries
Show the answer and explanation
Answer: A. Each parent-child relationship in the query counts as an extra query.
Subqueries do count, in both sync and async contexts.
Question 10. What’s the asynchronous limit for SOQL queries issued per transaction?
- A. 200
- B. 100
- C. 150
- D. 2,000
Show the answer and explanation
Answer: A. Asynchronous Apex can issue 200 SOQL queries; synchronous is 100.
150 is DML statements, and 2,000 is the SOSL row limit per query.
Before you move on
1. (Exam guide) How many scored questions are on the Platform Developer exam, and what’s the passing score?
Show answer
60 scored questions (plus up to 5 unscored), and 68% to pass.
2. (Exam guide) Which section carries the most weight?
Show answer
Process Automation and Logic, at 28%. Developer Fundamentals is 27%.
Key takeaways
- Multitenancy = shared resources, so Apex enforces governor limits per transaction.
- Limit exceptions can’t be caught. Bulkify instead.
- Sync/async: 100/200 SOQL, 150 DML statements, 50,000 rows retrieved, 10,000 DML rows, 10,000/60,000 ms CPU.
- DML on lists, SOQL outside loops, SOQL for loops for big result sets.
Sources
- Trailhead: Understand the Salesforce Architecture
- Apex Developer Guide: What is Apex?
- Apex Developer Guide: Execution Governors and Limits
- Apex Developer Guide: Running Apex within Governor Execution Limits
- Trailhead: Write SOQL Queries
Checked against Salesforce Help, Salesforce developer docs and Trailhead on Oct 10, 2026. Exam questions align to Summer ’25.
Liked this lesson?
There are 20 more like it, plus section checks, flashcards and 4 practice quizzes.
Start studying for $9.99