Governor Limits

Development 🔴 Advanced
📖 4 min read

Definition

Governor Limits are runtime limits enforced by the Salesforce platform that prevent any single transaction from monopolizing shared resources in the multitenant environment. They restrict the number of SOQL queries (100 per synchronous transaction), DML statements (150), callouts, heap size, CPU time, and other operations to ensure fair resource allocation across all tenants.

Real-World Example

A junior developer at ClearPath writes a trigger that queries the database inside a for-loop. When a bulk data load inserts 200 records, the trigger fires and attempts 200 SOQL queries, hitting the 100-query governor limit and throwing a System.LimitException. The senior developer refactors the code to bulkify it, moving the query outside the loop and processing all records with a single SOQL query and a single DML statement.

Why Governor Limits Matters

Governor Limits are runtime enforcement mechanisms in Salesforce's multitenant architecture that prevent any single transaction from consuming disproportionate shared resources. Since thousands of organizations share the same underlying infrastructure, these limits cap operations like SOQL queries at 100 per synchronous transaction, DML statements at 150, callouts at 100, heap size at 6 MB, and CPU time at 10,000 milliseconds. Without these guardrails, a single poorly written trigger or batch process could degrade performance for every other tenant on the same pod.

As a Salesforce org scales with more automation, integrations, and custom code, Governor Limits become the primary architectural constraint that developers must design around. Code that works perfectly with 10 records will catastrophically fail when processing 200 records if it contains queries or DML inside loops. Organizations that ignore bulkification best practices accumulate technical debt that eventually manifests as System.LimitExceptions during data migrations, bulk uploads, or peak usage periods. Mastering Governor Limits is non-negotiable for any team building enterprise-grade Salesforce solutions.

How Organizations Use Governor Limits

  • ClearPath Solutions — A junior developer at ClearPath Solutions wrote a trigger that queries the database inside a for-loop. When a bulk data load inserted 200 records, the trigger hit the 100-SOQL-query limit and threw a System.LimitException. The senior developer refactored the code by moving the query outside the loop and using a Map to process all records with a single query.
  • Orion Data Services — Orion Data Services was running a nightly batch integration that made individual API callouts for each of their 5,000 contact updates. They hit the callout governor limit repeatedly until they redesigned the integration to use composite API requests that bundle 200 records per callout, reducing total callouts from 5,000 to 25.
  • Vertex Cloud Technologies — Vertex Cloud Technologies experienced intermittent CPU time limit exceptions during complex opportunity roll-up calculations. By replacing recursive trigger patterns with a single-pass aggregation approach and leveraging Platform Events for asynchronous processing, they reduced CPU consumption by 80% and eliminated the timeout failures entirely.

🧠 Test Your Knowledge

💻 Developer Foundations: Next → Batch Apex

See something that could be improved?

Suggest an Edit