Governor Limits Explained
Because Salesforce runs on shared infrastructure where thousands of orgs coexist on the same servers, governor limits prevent any single transaction from consuming excessive CPU, memory, or database resources. Key limits include 100 SOQL queries per synchronous transaction (200 asynchronous), 150 DML statements per transaction, 10-second CPU time limit, 6 MB heap size, and 100 callouts per transaction. Exceeding any limit throws a System.LimitException that cannot be caught.
Understanding governor limits is fundamental to writing efficient Apex. Common patterns for staying within limits include bulkifying code (processing collections rather than single records), using Maps for O(1) lookups instead of nested loops with queries, leveraging SOQL aggregates to reduce query counts, and offloading heavy processing to asynchronous methods like Batch Apex, Queueable, or @future. The Limits class provides runtime methods (e.g., Limits.getQueries(), Limits.getDmlStatements()) to monitor consumption mid-transaction. Clientell AI generates governor-limit-safe code by default and can audit existing Apex for limit-risk patterns.
Related Salesforce Terms
Apex
Apex is Salesforce's proprietary, strongly-typed programming language used to execute custom business logic on the Lightning Platform.
Trigger
A Trigger in Salesforce is Apex code that executes automatically before or after DML events (such as insert, update, delete, or undelete) on a specific object.
Batch Apex
Batch Apex lets you process large volumes of records asynchronously by breaking them into manageable chunks that each run in their own execution context.
SOQL
SOQL (Salesforce Object Query Language) is the query language used to search and retrieve records from Salesforce's database.