Updated March 17, 2023
What are Governor Limits?
The apex runtime engine has set the limits to salesforce to make sure that the apex code or processes are executed normally without creating any kind of glitch.
All kinds of websites or applications run in a multi-tenant environment. Here the related resources of the application is been shared with other programs that are running parallelly on the platform.
Hence it is important that other applications don’t monopolize these shared resources, and thus, the governor limits are set.
Key Highlights
- Salesforce governor limits help different users in the platform without disturbing performance.
- Both hard and soft governor limits contain different types of limitations.
- The most popular Salesforce Governor Limits are SOQL 100 Limit and ML 150 Limit.
- Salesforce Governor Limits are fundamental due to the necessity of such limit grasp among salesforce developers.
An Introduction to Salesforce Governor Limits
- Salesforce Governor Limits is mainly usage caps enforced under Salesforce to ensure the process runs smoothly.
- Salesforce governor limit helps different users in the platform without disturbing performance.
- Several kinds of salesforce governor limits ensure safety and proper operations without impeding any performance.
- Some governor limits contain soft limits that can be solved with add-on purchases.
- On the other hand, some governor limits are tied to the salesforce edition (hard) and soft limits.
Types of Salesforce Governor Limits
Different types of Salesforce governor limits are
- Size Specific Apex limit, the size of code-related limits is present.
- Static Apex limits are related to different types of transactions.
- Lightning platform Apex limits are not specifically related to any Apex transaction but are enforced by the lightning platform.
- Transaction Apex limits are obtained as Apex limits for each transaction. Every Batch contains a different set of limits for executing a number of records in the execute method.
- The higher Per-Transaction Certified Package Limit is applied when salesforce ISV reviews a package after its creation and if it passes successfully.
Lists of Salesforce Governor limits
1. Apex Governor limits
- Apex Governor Limits are due to the strict limits ensured by Apex runtime because of the multitenant environment.
- If any Apex code limits are exceeded, then the related governor issues a runtime exception which is not easy to handle.
2. API request limits
- These are used to maintain optimum performance and ensure lightning platform API for customers and salesforce transactions through three limits.
- These include API timeout Limit, Total API request allocations, and Concurrent API request limits.
3. Connect rest API limits
- Connect rest API limits are for consumers.
- There is a rate limitation in connecting Rest API for per user, per application, hour, and rate limits.
4. Bulk API limits
- Bulk API limits & allocation are for batch allocation.
- It restricts batches after 15,000 per roll in one day or 24 hours.
5. API query cursor limit
- In a situation when a complex query cannot be returned in a single batch, then more server-side cursors are developed as query locators.
- API query cursor limits are limited to 10 cursors per user.
6. SOAP API call limit
- SOAP API call limits include the maximum number of records.
- These records are developed, the number of objects returned and records in the recycle bins.
Best of Salesforce Governor Limits
SOQL 100 limit
- This is one of the most common as well as popular salesforce governor limits in an apex class.
- This limit is that only 100 apex class/ execute anonymous scripts can be selected per apex transaction.
- When there are more than 99 accounts in the variable account list, the code will break.
- Thus, the simple solution for this limit is to move all SOQL statements out of for loops and maintain more collection and SOQL invention.
DML 150 Limit
- This is also a popular and well-known salesforce governor limit that is related to the number of DML operations in a particular transaction.
- There is a limit of 150 DML statement issues. To fix this limit issue, it is recommended not to use DML statements for loops.
- On the other hand, leveraging collections to store data is a great option, and it will ensure that DML operation on a particular collection is counted as one DML.
Importance of Salesforce Governor Limits
- Salesforce Governor Limits are very fundamental to the necessity of such limit grasp among salesforce developers.
- In addition, these limits are primarily developed to ensure required solutions in salesforce and the written codes.
- If the salesforce governor limit hits in any application or transaction, then the associate governor issues a runtime exception which is not manageable.
- It leads to the breakage of codes, and it will stop working.
Final Thoughts
Based on the overall discussion, it can be concluded that there are various salesforce governor limits for various reasons. It ensures the effective development of codes and maintenance of simplicity in salesforce testing. Different patterns can be used to manage such governor limits and stay below the limit requirement. SOQL and DML are the most popular and well-known Salesforce Governor limits. Managing a salesforce governor limit is both fun and challenging at the same time. Through proper measures and programming, the limits can be easily maintained.
FAQs(Frequently Asked Questions)
Q1. How can I monitor the governor limit in salesforce?
Answer: You can see limits from Setup>Company Information. Besides, you can see other limits like SOQL query, heap memory, and CPU time from the Utilities> Rest Explore option. Then click the GET option and execute the endpoint by /service/data/v43.0/limits.
Q2. What happens if an operation code exceeds the governor limit?
Answer: If any operation code exceeds the governor limit, then the associate governor will put a runtime exception in the code, which will make it stop working. The runtime execution is also not manageable.
Q3. Is it possible to use limit in SOQL query?
Answer: Limit is optional that can be added to the Select statement in a SOQL query to identify the maximum number of rows limit. LIMIT with count() can be used as fieldList to measure the maximum specific limit.
Recommended Articles
The above article is a guide to the Salesforce Governor Limits. To know more about the topic, you can refer to the below articles,