INTRODUCTION
What are Salesforce Governor Limits?
Types of Salesforce Governor Limits:
- Per-transaction Apex Limits
- Per-transaction Certified Managed Package Limits
- Size-specific Apex Limits
- Static Apex Limits
- Lightning Platform Apex Limits
- Miscellaneous Apex Limits
Per-transaction Apex Limits
Description |
Synchronous Limit |
Asynchronous Limit |
Total number of SOQL queries issued |
100 |
200 |
Total number of records retrieved by SOQL queries |
50,000 |
|
Total number of records retrieved by |
10,000 |
|
Total number of SOSL queries issued |
20 |
|
Total number of records retrieved by a single SOSL query |
2,000 |
|
Total number of DML statements issued |
150 |
|
The total number of records processed as a result of DML statements, Approval Process, or database.emptyRecycleBin |
10,000 |
|
Total stack depth for any Apex invocation that recursively fires triggers due to insert, update, or delete statements |
16 |
|
Total number of callouts (HTTP requests or Web services calls) in a transaction |
100 |
|
Maximum cumulative timeout for all callouts (HTTP requests or Web services calls) in a transaction |
120 seconds |
|
Maximum number of methods with the future annotation allowed per Apex invocation |
50 |
0 in batch and future contexts; 1 in queueable context |
Maximum number of Apex jobs added to the queue with System.enqueueJob |
50 |
1 |
Total number of send email methods allowed |
10 |
|
Total heap size |
6 MB |
12 MB |
Maximum CPU time on the Salesforce servers |
10,000 milliseconds |
60,000 milliseconds |
Maximum execution time for each Apex transaction |
10 minutes |
|
Maximum number of push notification method calls allowed per Apex transaction |
10 |
|
Maximum number of push notifications that can be sent in each push notification method call |
2,000 |
|
Maximum number of EventBus.publish calls for events configured to publish immediately |
150 |
Certified Managed packaged are the managed packages that have passed the AppExchange security review. Salesforce ISV Partners develop certified managed packages that have specific namespaces and are installed in your org. They get their own set of limits for most limits per transaction.
Description |
Collective Cross-Namespace Limit |
Total number of SOQL queries issued |
1,100 |
Total number of records retrieved by Database.getQueryLocator |
110,000 |
Total number of SOSL queries issued |
220 |
Total number of DML statements issued |
1,650 |
Total number of callouts (HTTP requests or Web services calls) in a transaction |
1,100 |
Total number of send email methods allowed |
110 |
- The maximum transaction execution time
- The maximum number of unique namespaces
- The maximum CPU time
- The total heap size
Size-specific Apex Limits
Description |
Limit |
Maximum number of characters for a class |
1 million |
Maximum number of characters for a trigger |
1 million |
The maximum amount of code used by all Apex code in an org |
6 MB |
Method size limit |
65,535 bytecode instructions in compiled form |
Static Apex Limits
Description |
Limit |
Default timeout of callouts (HTTP requests or Web services calls) in a transaction |
10 seconds |
Maximum size of callout request or response (HTTP request or Web services call) |
6 MB for synchronous Apex or 12 MB for asynchronous Apex |
Maximum SOQL query run time before Salesforce cancels the transaction |
120 seconds |
Maximum number of class and trigger code units in a deployment of Apex |
5,000 |
Apex trigger batch size |
200 |
For loop list batch size |
200 |
Maximum number of records returned for a Batch Apex query in Database.QueryLocator |
50 million |
Lightning Platform Apex Limits
Description |
Limit |
The maximum number of asynchronous Apex method executions (batch Apex, future methods, Queueable Apex, and scheduled Apex) per a 24-hour period |
250,000 or the number of user licenses in your org multiplied by 200, whichever is greater |
Number of synchronous concurrent transactions for long-running transactions that last longer than 5 seconds for each org. |
10 |
Maximum number of Apex classes scheduled concurrently |
100. In Developer Edition orgs, the limit is 5. |
Maximum number of batch Apex jobs in the Apex flex queue that are in Holding status |
100 |
Maximum number of batch Apex jobs queued or active concurrently |
5 |
Maximum number of batch Apex job start method concurrent executions |
1 |
Maximum number of batch jobs that can be submitted in a running test |
5 |
Maximum number of test classes that can be queued per 24-hour period (production orgs other than Developer Edition) |
The greater of 500 or 10 multiplied by the number of test classes in the org |
Maximum number of test classes that can be queued per 24-hour period (sandbox and Developer Edition orgs) |
The greater of 500 or 20 multiplied by the number of test classes in the org |
Maximum number of query cursors open concurrently per user |
50 |
Maximum number of query cursors open concurrently per user for the Batch Apex start method |
15 |
Maximum number of query cursors open concurrently per user for the Batch Apex execute and finish methods |
5 |
Miscellaneous Apex Limits
Advantages of Governor Limits
- Apex has coding limitations that are entirely different or unique.
- Governor limits help us remain inside the required apex coding place.
- Governor limits prevent other org to take up a lot of space in memory.
How to avoid Governor Limits
- In For Loops, do not use SOQL queries and DML statements
- Ensure that the Apex code manage more than one record at a time
- Querying vast amounts of data
- Use Batch Apex for 50,000 records
- Organize multiple triggers on the same page
- Use collection for loops
- Use @future annotation
- Use of the Limits Apex Methods to Avoid Hitting Governor Limits