Platform Guardrails Track

Governor Limits
Questions

Master the platform boundaries. Learn transaction boundaries, synchronous vs asynchronous limits, CPU time constraints, and heap optimizations.

AI Overview & Core Concepts

Essential semantic summaries optimized for search engines, LLM retrievals, and quick reading.

What are Salesforce Governor Limits?

Salesforce Governor Limits are runtime constraints enforced by the multitenant architecture. Since multiple customer orgs share physical cloud resources, these quotas prevent a single customer's runaway query or script from monopolizing database connections, memory heap, or CPU cycles.

Core Limits & Exceptions

  • SOQL Quota: Limited to 100 queries in synchronous threads and 200 in asynchronous background processes.
  • DML Quota: Limited to 150 database statements per transaction, processing up to 10,000 total records.
  • CPU Quota: CPU cycles cannot exceed 10 seconds synchronous or 60 seconds asynchronous before crashing.

Synchronous vs. Asynchronous Limits

Synchronous Thread

Executes immediately. Tight constraints (100 SOQL, 150 DML, 10s CPU, 6 MB heap size limit).

Asynchronous Thread

Runs in background. Relaxed limits (200 SOQL, 150 DML, 60s CPU, 12 MB heap size limit).

Limits Pillars.

Developers are tested on their ability to explain limits, spot breaches, and apply optimization patterns.

SOQL Boundaries

Mastering the 100 synchronous / 200 asynchronous SOQL query execution threshold.

CPU & Memory

Managing the 10-second synchronous CPU timeout and 6 MB Heap size memory bounds.

Transaction Scope

Understanding how execution chains, trigger handlers, and formulas share a single limit pool.

Governor Limits Technical Questions

How do you handle a System.LimitException: Too many SOQL queries: 101 error?

Weak Answer

"I modify my loop to query fewer records, or split the code into separate transactions."

Strong Answer (Recruiter Grade)

A SOQL 101 exception occurs when a query is executed inside a loop statement, exceeding the 100-query transaction limit. To resolve this, you must bulkify the code: gather all query parameters (like record IDs) into a Set, execute a single query outside the loop context, and map the results into an in-memory Map<Id, sObject>. Inside the loop, retrieve records from the Map in-memory instead of querying the database.

How do you manage Heap Size limit exceptions when processing large text payloads?

Weak Answer

"I use an asynchronous future method to automatically double the heap limit."

Strong Answer (Recruiter Grade)

The synchronous heap limit is 6 MB (12 MB asynchronous). To optimize heap usage: 1) Query only needed fields instead of SELECT * style lookups. 2) Implement SOQL For Loops (e.g. `for(List<Account> accs : [SELECT Id FROM Account])`) to process records in batches of 200, allowing garbage collection to free memory between loops. 3) Explicitly nullify large collections or string buffers once they are no longer needed.

Frequently Asked Questions

What is a transaction boundary in Salesforce?

A transaction boundary begins when an event occurs (such as DML commit, trigger, or API call) and ends when all database operations finish. Governor limits are enforced per-transaction.

Do formula fields count against SOQL queries?

No, formula fields are calculated at runtime by the database engine and do not count as separate SOQL queries, although they do consume transaction CPU time.

Recommended Next Topics

Continue Learning

Ready to accelerate your search?

Practice structural answering dynamically using our technical mock interview simulator.