About Me

My photo
PLANO, Texas, United States

Tuesday, December 29, 2015

Governor Limits

Governor limits are the apex run time limits enforced by the apex run time engine. If you write non-optimized code, your application will get slow and you will see performance issues down the line. But if you write very bad code, salesforce ensures that you will not be using the resource from other applications imposing the governor limit.


Why this is useful: As Apex runs on the shared and multi-tenant environment (Where multiple resources can use the single application at a time), governor limits ensure that code does not monopolize the resource, and each and every user can use the system with no unexpected error.


What happens when code exceeds the limit: If your code exceeds a limit, the associated governor throws the exception error and terminates the request. 


How to take care of governor limits: While writing the code, we must take care of the governor limits and should write the optimized code and should use the best practice of apex. Like avoiding the Too Many SOQL queries, we must ensure the query is not within the “for loop” or particular trigger is not getting fired multiple times. Also if you have a large number of data, we can use the asynchronous class (Batch class)


Important Governor limits:

No of SOQL Query: 100

No of query rows: 50K

No of SOSL: 20

No of DML: 150

No of DML rows:  10K

Maximum Heap Size: 6 MB

Number of future calls: 50