Call Us Today !

How to Execute Governors and Limits in Salesforce

Salesforce enforces limits on Apex codes to ensure that only efficient codes are written and used within the platform. If a certain Apex code does exceed a pre-defined limit, the related governor gives a corresponding error message that the code cannot be handled anymore.

This short post will delve deeper on what these limits are in Salesforce.

What is a Governor?

Governor is another term for an Apex code limit. These limits are strictly used in Salesforce because the Apex runtime environment is a multitenant one, and therefore a running code should not monopolize Salesforce shared resources. The governor follows and imposes limit statistics based on various Salesforce sections.

Here is an example of a governor limit error message that a user could get after attempting to run bad code:

Too many SOQL queries: 101

There are many Salesforce sections that enforce governor limits. Among these are Static Apex limits, Apex limits, Per-Transaction limits and Miscellaneous Apex limits.

Pros and Cons of Governors

Here are the advantages and disadvantages of governors in Salesforce:


  • Developers are forced to write and run scalable codes only
  • The limits stop other orgs from creating bad codes
  • Governor limits prevent memory pooling from bad codes in a cloud CPU
  • Governor limits are a unique security feature for Apex environments


  • Governor limits will never increase. They remain the same throughout the entire Salesforce. It won’t increase even if a user pays for a higher Salesforce edition or not.
  • Org developers may encounter hard limits that prevent them from doing some tasks.

Execution of Governor Limits and how to Beat Them

Governor limits are actually pre-defined. A developer must create code that can be freely executed without exceeding these pre-defined governor limits. If not, the governor limit will run and display error messages stating that the code cannot be allowed to run because it has reached a limit.

Writing efficient code does not only help keep governor limits at bay. It also helps save up resources and make coding easier and faster in the cloud.

Governor limits generally don’t increase. The only way to beat these limits, as previously stated, is to write good code and avoid bad coding practices. Apex must be run within these governor limits in order to avoid erroneous governor limit executions.

Share this article!

Partager sur facebook
Partager sur twitter
Partager sur linkedin
Partager sur email