Salesforce Governor Limits are restrictions imposed by the Salesforce platform to ensure the efficient use of shared resources, maintain system performance, and prevent monopolization of system resources by any single organization or user. These limits apply to various aspects of Salesforce, including data manipulation, processing, and storage. Adhering to these limits is crucial for maintaining the stability and performance of your Salesforce org.
Here are some common Salesforce Governor Limits along with best practices and examples:
1. SOQL (Salesforce Object Query Language) Query Limit:
– Limit: 100 queries per transaction.
– Best Practices: Optimize queries by fetching only necessary fields and filtering records efficiently.
Example:
List<Account> accList = [SELECT Id, Name FROM Account WHERE Industry = ‘Technology’ LIMIT 100];
2. DML (Data Manipulation Language) Statement Limit:
– Limit: 150 DML statements per transaction.
– Best Practices: Combine multiple DML operations into fewer statements using collections.
Example:
List<Account> accListToUpdate = [SELECT Id, Name FROM Account WHERE Industry = ‘Technology’ LIMIT 100];
For (Account acc : accListToUpdate) {acc.Industry = ‘Software’;} update accListToUpdate;
3. CPU Time Limit:
– Limit: Maximum CPU time of 10,000 milliseconds per transaction.
– Best Practices: Optimize code execution by reducing loops, avoiding unnecessary calculations, and using asynchronous processing for long-running operations.
Example:
Integer total = 0; for (Integer i=0; i<100000; i++) {total += i;}
4. Heap Size Limit:
– Limit: Maximum heap size of 6 MB for synchronous transactions.
– Best Practices: Minimize memory usage by limiting the size of collections, avoiding unnecessary variables, and using efficient data structures.
Example:
List<String> stringList = new List<String>();
for(Integer i=0; i<100000; i++) {stringList.add(‘String ‘ + i)}
5. Email Limit:
– Limit: Maximum of 5,000 emails per organization per day.
– Best Practices: Use email templates, avoid sending duplicate emails, and implement email governance.
Example: Sending automated notifications to users.
6. API Request Limit:
– Limit: Daily limit varies based on Salesforce Edition and license type.
– Best Practices: Optimize API usage by reducing unnecessary calls, implementing batching, and using appropriate API versions.
Example: Integrating Salesforce with external systems using REST or SOAP APIs.
7. Storage Limit:
– Limit: Maximum data storage allocated based on Salesforce Edition.
– Best Practices: Regularly monitor and clean up unused data, leverage Salesforce features like data archiving, and consider external storage options.
Example: Storing records such as Accounts, Contacts, and Opportunities.
Summary
By understanding and adhering to these Governor Limits, you can ensure the efficient and effective utilization of Salesforce resources while building robust and scalable applications on the platform.
For more updates about Salesforce, visit us on www.thesalesforcemaster.com