Tip of the Day : Set up email alerts for high-priority cases to improve response times.

Salesforce Governor Limits: What They Are and Why They Matter?

January 06, 2026
253 Views
Salesforce Governor Limits: What They Are and Why They Matter?
Summarize this blog post with:

Salesforce is a robust cloud platform, used by millions of people and thousands of companies around the world. It’s remarkable because of the way customers can customise and extend functionality with Apex code, declarative automation, integrations and more. Still, there are challenges to executing custom logic in a shared, multi-tenant environment, and those challenges are addressed by the Salesforce Governor Limits.

Governor limits are rules enforced by the Salesforce platform to prevent individual transactions from consuming excessive resources on shared servers. They provide fairness in diligence and performance stability to be shared among all tenants. Although some of these limits can be surprising at first, knowing the reasons behind the limits and how to work around them is key to developing scalable, robust solutions on Salesforce.

In this blog, the concept of governor limits is explained, along with why Salesforce enforces them, the key types of limits most commonly encountered, and best practices for designing solutions that stay within these limits.

What Are Salesforce Governor Limits?

In essence, governor limits are system resource limits that determine how many resources, such as CPU usage, memory consumption, etc., one execution of Salesforce code can consume. This applies whether you’re executing Apex code, running flows, or processing triggers.

If your logic consumes too many resources, like too many database queries or DML operations, Salesforce stops the transaction with an error, preventing further processing. These limits aren’t arbitrary; they are a key part of Salesforce’s multi-tenant architecture.

Imagine an apartment building with shared water pressure. If one tenant opens every tap at full blast while another runs a washing machine and someone else showers, the system can fail. Governor limits prevent this kind of resource monopolization across tenants in Salesforce.

Why Salesforce Enforces Governor Limits?

Salesforce runs thousands of orgs known as tenants on shared infrastructure. If one tenant wrote inefficient or unbounded code, it could degrade performance for others. Governor limits serve several important purposes,
  • Fair Resource Sharing: Each org must get a fair allocation of computing power, memory, API calls, and database access. Without limits, one heavy transaction could monopolise resources and slow down the entire system.
  • Stability and Predictability: Limits prevent runaway processes such as infinite loops or unbounded queries. This ensures that runtimes remain predictable and systems stay responsive for all users.
  • Encouraging Efficient Design: Governor limits also incentivise developers to consider efficiency and optimisation when writing code. This results in cleaner code and better long-term performance of the applications.

Key Types of Salesforce Governor Limits

Governor limits come in many forms, and it’s helpful to understand the categories you’re most likely to hit during development.

1. Per-Transaction Apex Limits

These limits apply to a single execution context of Apex code (such as a trigger or batch chunk). For example:

  • Maximum number of SOQL queries
  • Maximum number of SOSL queries
  • Maximum number of DML statements
  • Maximum number of records retrieved
  • Maximum heap size (memory)

These limits reset for each transaction. If any limit is exceeded mid-execution, the entire transaction fails

2. Lightning Platform Limits

Some governor limits are enforced at the platform level rather than per transaction. These include limits such as:

  • Asynchronous Apex executions per 24 hours
  • Concurrent long-running transactions
  • Scheduled Apex jobs

These help keep platform processes manageable across large orgs.

3. Managed Package Limits

Certified managed packages (such as AppExchange apps) often have their own namespace-specific governor limits, which may be higher or separate from standard limits. This allows partners to build powerful apps without disrupting tenant limits.

4. Static and Size-Specific Limits

These include limits such as total Apex code size per org, although some can be increased upon request through Salesforce support.

Real Examples of Salesforce Governor Limits

Here are a few concrete limits that developers commonly watch out for:

SOQL Query Limits

  • Up to 100 SOQL queries per synchronous transaction
  • Up to 200 SOQL queries for asynchronous transactions

This means if you run a SOQL query inside a loop, a classic anti-pattern, you can easily hit the limit and cause an uncatchable runtime exception.

DML Operations

  • 150 DML operations per transaction
Attempting more DML operations than this in one transaction, for example, by inserting one record at a time in a loop, will trigger a governor limit error.

Heap Size

  • synchronous heap size is limited (e.g., 6 MB)
  • Asynchronous processes often have larger limits
Loading too many records into memory at once can push systems over this limit.

Callouts and Other Methods

  • Maximum number of HTTP callouts per transaction
  • Limits on methods like sending email or queueable jobs
These limits help prevent excessive integration or messaging workloads in a single transaction.

How Governor Limits Affect Salesforce Development?

When first learning Salesforce, many developers encounter governor limit exceptions as a surprise. But these limits have direct implications on how you design logic,
  • Triggers and Flows must be bulkified so multiple records are processed in one go rather than one at a time.
  • Queries should be efficient and selective return only fields needed and limit the scope of returned records.
  • Loops should avoid SOQL and DML operations inside them moving queries outside loops dramatically reduces consumption of limits.
  • Heavy work should be performed asynchronously using future methods, Queueable Apex, or Batch Apex. so it can be divided into multiple transactions.
Understanding how limits interact with automations, especially when multiple automations (e.g., triggers, flows, process builders) fire together, is critical to avoiding runtime failures in busy production environments.

Best Practices to Design Around Governor Limits

Here are proven ways to build Salesforce logic that avoids hitting governor limits,
1. Bulkify Code and Automation
Design your code with the expectation that it will be dealing with lists of records and not just one record at a time. Such as, instead of querying inside a loop, collect IDs first, then query once outside the loop. This approach drastically decreases the number of SOQL queries executed.
2. Optimise SOQL Queries
  • Use WHERE clauses to limit returned rows.
  • Only retrieve the fields you need.
  • Consider indexed fields for filters to speed up queries.
Efficient queries reduce heap usage and CPU time while staying within limits.
3. Use Collections Wisely
Use Lists, Sets, and Maps to store and reference records efficiently without repeated queries or DML operations. For example, storing multiple IDs in a Set avoids duplicate operations.
4. Use Asynchronous Apex
Large data jobs should be moved into Batch Apex, Queueable Apex, or future methods so that each piece is processed in separate transactions with fresh limits.
5. Centralise Logic Where Possible
Avoid multiple trigger contexts firing similar logic. Instead, use handler frameworks that process logic in centralised, controlled ways to prevent duplication and unnecessary DML/SOQL usage
6. Monitor and Debug Limit Usage
Make use of debug logs, limit classes (Limits.getLimitXXX()), and performance tools to monitor how close your code gets to limits so you can adjust before issues occur

What Happens When a Limit Is Exceeded?

If a governor limit is exceeded in a transaction, Salesforce throws an uncatchable exception, and the entire transaction is rolled back. This means,
  • The operation stops
  • No partial changes are saved
  • The user sees an error unless handled explicitly
This behaviour underscores why building with limits in mind is essential rather than reacting to errors after they occur.

Governor Limits and Salesforce Flows

While much attention is on Apex, declarative automation tools such as Flow and Process Builder also play into governor limits, especially when they interact with large data sets or chain multiple actions. Complex flows with loops and sub-flows can consume limits quickly. Always test flows with representative data volumes and implement data filtering and fast field updates where possible.

Summary

Salesforce governor limits are in place due to the shared multi-tenant platform architecture to guarantee fair usage of system resources, such as CPU, memory, database queries, and API calls, across all orgs. While these constraints may seem overly limiting at first, they are necessary for keeping the platform stable, providing predictable performance, and preventing one tenant from adversely impacting others due to inefficient or runaway code.

Rather than being obstacles, Salesforce governor limits encourage developers to design scalable and efficient solutions. Teams can develop scalable applications capable of handling expanding data volumes through the use of bulkification of logic, optimisation of SOQL queries, efficient use of collections, and asynchronous processing. Understanding and designing around governor limits is a fundamental skill that separates basic Salesforce implementations from truly enterprise-ready solutions.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Written by

Mohit Bansal

Salesforce Technical Architect | Lead | Salesforce Lightning & Integrations Expert | Pardot | 5X Salesforce Certified | App Publisher | Blogger

Get the latest tips, news, updates, advice, inspiration, and more….

Contributor of the month
contributor
Khumed Khatib

8x Salesforce certified || Blogger || LWC || Aura||

...
Categories
...
Boost Your Brand's Visibility

Want to promote your products/services in front of more customers?

...

Leave a Reply

Your email address will not be published. Required fields are marked *