Execution Governor & Limits
Execution Governor & Limits – to ensure that no one transaction monopolizes shared resources.
These governor execution limits are per transaction.
Per-Transaction Apex Limits
Static Apex Limits
- 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.