Execution Governor & Limits

Execution Governor & Limits – to ensure that no one transaction monopolizes shared resources. 

These governor execution limits are per transaction.
OBJECT LIMITS
Item
Limit
Custom Fields
500
Custom Relationship Fields
25 (Max 2 Master Detail Relations rest all Lookup Relationships)
Active Workflow Rules
50
Total Workflow Rules
300
Approval Processes
500
Active Lookup Filters
5
Active Validation Rules
100
VLOOKUP Functions
10
Sharing Rules (Both Owner- and Criteria-based)
300
Sharing Rules (Criteria-based Only)
50

Per-Transaction Apex Limits
Description
Synchronous Limit
Asynchronous Limit
Total number of SOQL queries issued1
100
200
Total number of records retrieved by SOQL queries
50,000
Total number of records retrieved by Database.getQueryLocator
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 issued2
150
Total number of records processed as a result of DML statements, Approval.process, or database.emptyRecycleBin
10,000
Total heap Size
6MB
12MB

Static Apex Limits
Maximum number of records returned for a Batch Apex query in Database.QueryLocator
50 million
For Loop list Batch Size
200


Best Practices
-      Bulkifying DML calls - Making DML calls on lists of sObjects instead of each individual sObject makes it less likely to reach the DML statements limit.

-      More efficient SOQL queries – do not place SOQL queries inside for loop, find some other alternate like nested queries.


-      SOQL For Loops - Use SOQL for loops to operate on records in batches of 200. This helps avoid the heap size limit of 6 MB this limit is for code running synchronously and it is higher for asynchronous code execution.


Governor limits apply to all Salesforce instances (trial, developer, production or sandbox environments). However code coverage and successful execution of test classes is only enforced when deploying to a production environment.

Comments