Governor limits

Shivanath Devinarayanan
Shivanath DevinarayananSalesforce.com MVP | Force.com MVP | CEO | Architect | Certified Salesforce Administrator & Developer
In depth view of the governor limits in apex SalesForce
                                           SHIVANATH.D
What are Governor Limits ?
• Runtime limits enforced by apex
• Ensures no monopoly in resources.
                                      Memory
• Similar to heap size in Java.
• Back bone of MULTI-TENANT
architecture.                         Database Resources
• The Organization Shares the limit
                                      No of Script Statements


                                      No of Records processed
How are Governor Limits Calculated?
There are a number of factors that
determine what governor limit is
used, and when it is applied
                                     Invocation of Apex-Entry


                                     How Many Records


                                     Which Governor Limit
Entry Point
• Governor limits are applied based
on the entry point                       Apex Trigger
•insert, update, delete, merge,
upsert, and undelete are the Trigger
                                         Apex Web service
operations
• All Apex triggers are bulk triggers.
• Batch of up to 200 records             Anonymous Block
• Anonymous block does not get
stored in the metadata                   Visualforce Controller
•Run Tests is a Force.com Web
Services API call used to execute test
methods                                  Run Tests
Governor Limit Scope
• Governor Limits are shared by the
organization
                                         Maximum of 100 SOQL Queries
•From beginning till end of
execution
                                         Max of 50,000rows retrieved
•Governor limits are not specified for
each separate trigger.                   Max of 200,000 scripts executed
•Any Apex class, method, or trigger
invoked by code executed within the      Max 50 million Batch SOQL
entry point will count towards the
same governor limits as it's a           Batches of up to 2,000 records
synchronous request
Synchronous vsAsynchronous Apex
• Normal Execution Synchronous
•@future is asynchronous
                                 Synchronous
•Business Logic is offloaded
•Efficiency increases
• but , more callouts
                                     VS


                                 Asynchronous
Governor limits
Limits
SOQL statements issued in a request.
Database.countQuery
Database.getQueryLocator
Database.query
DML queries issued in a request.
Approval.process
Database.convertLead
Database.emptyRecycleBin
Database.rollback
Database.setSavePoint
delete and Database.delete
insert and Database.insert
merge
undelete and Database.undelete
update and Database.update
upsert and Database.upsert
System.runAs
Bulkify your Code
Poorly Written Code




Bulkified Code
Avoid SOQL Queries inside FOR Loops
Avoid SOQL Queries inside FOR Loops
Use Collections in code
Streamlining Multiple Triggers on the
Same Object

           • Merge if triggers are redundant
              • Triggers same share limit
            • Easy to hit the governor limits
Querying Large Data Sets
Use @futureAppropriately




Don’t do this !
Q &A
1 of 16

Recommended

Batch Apex in Salesforce by
Batch Apex in SalesforceBatch Apex in Salesforce
Batch Apex in SalesforceDavid Helgerson
2.4K views28 slides
Episode 19 - Asynchronous Apex - Batch apex & schedulers by
Episode 19 - Asynchronous Apex - Batch apex & schedulersEpisode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulersJitendra Zaa
10.6K views22 slides
Apex code (Salesforce) by
Apex code (Salesforce)Apex code (Salesforce)
Apex code (Salesforce)Mohammed Safwat Abu Kwaik
2.4K views161 slides
Salesforce Basic Development by
Salesforce Basic DevelopmentSalesforce Basic Development
Salesforce Basic DevelopmentNaveen Dhanaraj
485 views38 slides
Introduction to Apex Triggers by
Introduction to Apex TriggersIntroduction to Apex Triggers
Introduction to Apex TriggersSalesforce Developers
2.2K views24 slides
Salesforce asynchronous apex by
Salesforce asynchronous apexSalesforce asynchronous apex
Salesforce asynchronous apexBadan Singh Pundeer
7.5K views12 slides

More Related Content

What's hot

Introduction to lightning Web Component by
Introduction to lightning Web ComponentIntroduction to lightning Web Component
Introduction to lightning Web ComponentMohith Shrivastava
2.8K views25 slides
Introduction to Apex for Developers by
Introduction to Apex for DevelopersIntroduction to Apex for Developers
Introduction to Apex for DevelopersSalesforce Developers
3.6K views56 slides
Salesforce customization vs configuration by
Salesforce customization vs configurationSalesforce customization vs configuration
Salesforce customization vs configurationCloud Analogy
760 views11 slides
Asynchronous Apex Salesforce World Tour Paris 2015 by
Asynchronous Apex Salesforce World Tour Paris 2015Asynchronous Apex Salesforce World Tour Paris 2015
Asynchronous Apex Salesforce World Tour Paris 2015Samuel De Rycke
2.1K views32 slides
Batchable vs @future vs Queueable by
Batchable vs @future vs QueueableBatchable vs @future vs Queueable
Batchable vs @future vs QueueableBoris Bachovski
17.2K views9 slides

What's hot(20)

Salesforce customization vs configuration by Cloud Analogy
Salesforce customization vs configurationSalesforce customization vs configuration
Salesforce customization vs configuration
Cloud Analogy760 views
Asynchronous Apex Salesforce World Tour Paris 2015 by Samuel De Rycke
Asynchronous Apex Salesforce World Tour Paris 2015Asynchronous Apex Salesforce World Tour Paris 2015
Asynchronous Apex Salesforce World Tour Paris 2015
Samuel De Rycke2.1K views
Batchable vs @future vs Queueable by Boris Bachovski
Batchable vs @future vs QueueableBatchable vs @future vs Queueable
Batchable vs @future vs Queueable
Boris Bachovski17.2K views
Coding for Declarative Customizations: How We Do It in Salesforce.com IT by Salesforce Developers
Coding for Declarative Customizations: How We Do It in Salesforce.com ITCoding for Declarative Customizations: How We Do It in Salesforce.com IT
Coding for Declarative Customizations: How We Do It in Salesforce.com IT
Performance Monitoring and Testing in the Salesforce Cloud by Salesforce Developers
Performance Monitoring and Testing in the Salesforce CloudPerformance Monitoring and Testing in the Salesforce Cloud
Performance Monitoring and Testing in the Salesforce Cloud
Salesforce Developers28.3K views
Lwc presentation by Nithesh N
Lwc presentationLwc presentation
Lwc presentation
Nithesh N1.9K views
Sql Server Performance Tuning by Bala Subra
Sql Server Performance TuningSql Server Performance Tuning
Sql Server Performance Tuning
Bala Subra7.5K views
Microsoft Azure and Windows Application monitoring by Site24x7
Microsoft Azure and Windows Application monitoringMicrosoft Azure and Windows Application monitoring
Microsoft Azure and Windows Application monitoring
Site24x71.6K views
All About Test Class in #Salesforce by Amit Singh
All About Test Class in #SalesforceAll About Test Class in #Salesforce
All About Test Class in #Salesforce
Amit Singh1.8K views
Salesforce data model by Jean Brenda
Salesforce data modelSalesforce data model
Salesforce data model
Jean Brenda519 views
Flow builder pros and cons by Melissa Shook
Flow builder pros and consFlow builder pros and cons
Flow builder pros and cons
Melissa Shook1.1K views
Episode 10 - External Services in Salesforce by Jitendra Zaa
Episode 10 - External Services in SalesforceEpisode 10 - External Services in Salesforce
Episode 10 - External Services in Salesforce
Jitendra Zaa2.4K views
Lightning web components episode 2- work with salesforce data by Salesforce Developers
Lightning web components   episode 2- work with salesforce dataLightning web components   episode 2- work with salesforce data
Lightning web components episode 2- work with salesforce data
Salesforce Developers11.7K views
Dynamic input tables lwc vs aura vs. visualforce by Mike Tetlow
Dynamic input tables  lwc vs aura vs. visualforceDynamic input tables  lwc vs aura vs. visualforce
Dynamic input tables lwc vs aura vs. visualforce
Mike Tetlow303 views
Microservices with Java, Spring Boot and Spring Cloud by Eberhard Wolff
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
Eberhard Wolff14.9K views
SOQL in salesforce || Salesforce Object Query Language || Salesforce by Amit Singh
SOQL in salesforce || Salesforce Object Query Language || SalesforceSOQL in salesforce || Salesforce Object Query Language || Salesforce
SOQL in salesforce || Salesforce Object Query Language || Salesforce
Amit Singh2K views

Similar to Governor limits

Introduction to weblogic by
Introduction to weblogicIntroduction to weblogic
Introduction to weblogicVishal Srivastava
483 views18 slides
Salesforce app limits_cheatsheet latest by 25 oct 2019 by
Salesforce app limits_cheatsheet latest by 25 oct 2019Salesforce app limits_cheatsheet latest by 25 oct 2019
Salesforce app limits_cheatsheet latest by 25 oct 2019Swarup Hait
59 views16 slides
Dealing with and learning from the sandbox by
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandboxElaine Van Bergen
554 views40 slides
Dealing with and learning from the sandbox by
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandboxElaine Van Bergen
447 views40 slides
4. (mjk) extreme performance 2 by
4. (mjk) extreme performance 24. (mjk) extreme performance 2
4. (mjk) extreme performance 2Doina Draganescu
555 views27 slides
AWS Kinesis - Streams, Firehose, Analytics by
AWS Kinesis - Streams, Firehose, AnalyticsAWS Kinesis - Streams, Firehose, Analytics
AWS Kinesis - Streams, Firehose, AnalyticsSerhat Can
747 views35 slides

Similar to Governor limits(20)

Salesforce app limits_cheatsheet latest by 25 oct 2019 by Swarup Hait
Salesforce app limits_cheatsheet latest by 25 oct 2019Salesforce app limits_cheatsheet latest by 25 oct 2019
Salesforce app limits_cheatsheet latest by 25 oct 2019
Swarup Hait59 views
Dealing with and learning from the sandbox by Elaine Van Bergen
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandbox
Elaine Van Bergen554 views
Dealing with and learning from the sandbox by Elaine Van Bergen
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandbox
Elaine Van Bergen447 views
AWS Kinesis - Streams, Firehose, Analytics by Serhat Can
AWS Kinesis - Streams, Firehose, AnalyticsAWS Kinesis - Streams, Firehose, Analytics
AWS Kinesis - Streams, Firehose, Analytics
Serhat Can747 views
ENT309 scaling up to your first 10 million users by Amazon Web Services
ENT309 scaling up to your first 10 million usersENT309 scaling up to your first 10 million users
ENT309 scaling up to your first 10 million users
Amazon Web Services5.6K views
ENT309 Scaling Up to Your First 10 Million Users by Amazon Web Services
ENT309 Scaling Up to Your First 10 Million UsersENT309 Scaling Up to Your First 10 Million Users
ENT309 Scaling Up to Your First 10 Million Users
Amazon Web Services21.6K views
ENT309 Scaling Up to Your First 10 Million Users by Amazon Web Services
ENT309 Scaling Up to Your First 10 Million UsersENT309 Scaling Up to Your First 10 Million Users
ENT309 Scaling Up to Your First 10 Million Users
Server Day 2009: Oracle/Bea Fusion Middleware by Paolo Ramasso by JUG Genova
Server Day 2009: Oracle/Bea Fusion Middleware by Paolo RamassoServer Day 2009: Oracle/Bea Fusion Middleware by Paolo Ramasso
Server Day 2009: Oracle/Bea Fusion Middleware by Paolo Ramasso
JUG Genova722 views
DOES SFO 2016 - Avan Mathur - Planning for Huge Scale by Gene Kim
DOES SFO 2016 - Avan Mathur - Planning for Huge ScaleDOES SFO 2016 - Avan Mathur - Planning for Huge Scale
DOES SFO 2016 - Avan Mathur - Planning for Huge Scale
Gene Kim628 views
Oleksandr Khotemskyi - Serverless architecture and how to apply it in Automa... by Web Tech Fun
Oleksandr Khotemskyi  - Serverless architecture and how to apply it in Automa...Oleksandr Khotemskyi  - Serverless architecture and how to apply it in Automa...
Oleksandr Khotemskyi - Serverless architecture and how to apply it in Automa...
Web Tech Fun 23 views
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац... by Dakiry
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Dakiry81 views
Cost Effectively Run Multiple Oracle Database Copies at Scale by NetApp
Cost Effectively Run Multiple Oracle Database Copies at Scale Cost Effectively Run Multiple Oracle Database Copies at Scale
Cost Effectively Run Multiple Oracle Database Copies at Scale
NetApp315 views
DevDay: Corda Enterprise: Journey to 1000 TPS per node, Rick Parker by R3
DevDay: Corda Enterprise: Journey to 1000 TPS per node, Rick ParkerDevDay: Corda Enterprise: Journey to 1000 TPS per node, Rick Parker
DevDay: Corda Enterprise: Journey to 1000 TPS per node, Rick Parker
R3824 views
ENT309 Scaling Up to Your First 10 Million Users by Amazon Web Services
ENT309 Scaling Up to Your First 10 Million UsersENT309 Scaling Up to Your First 10 Million Users
ENT309 Scaling Up to Your First 10 Million Users
Prometheus lightning talk (Devops Dublin March 2015) by Brian Brazil
Prometheus lightning talk (Devops Dublin March 2015)Prometheus lightning talk (Devops Dublin March 2015)
Prometheus lightning talk (Devops Dublin March 2015)
Brian Brazil465 views
Migrating enterprise workloads to AWS by Tom Laszewski
Migrating enterprise workloads to AWS Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWS
Tom Laszewski9.1K views
Stream Computing (The Engineer's Perspective) by Ilya Ganelin
Stream Computing (The Engineer's Perspective)Stream Computing (The Engineer's Perspective)
Stream Computing (The Engineer's Perspective)
Ilya Ganelin911 views

More from Shivanath Devinarayanan

Salesforce Lightning workshop by
Salesforce Lightning workshopSalesforce Lightning workshop
Salesforce Lightning workshopShivanath Devinarayanan
8.5K views61 slides
Force.com Friday - Intro to Force.com by
Force.com Friday -  Intro to Force.comForce.com Friday -  Intro to Force.com
Force.com Friday - Intro to Force.comShivanath Devinarayanan
542 views16 slides
Salesforce_Certified_Administrator by
Salesforce_Certified_AdministratorSalesforce_Certified_Administrator
Salesforce_Certified_AdministratorShivanath Devinarayanan
253 views1 slide
Force.com Friday - Intro to Visualforce by
Force.com Friday - Intro to VisualforceForce.com Friday - Intro to Visualforce
Force.com Friday - Intro to VisualforceShivanath Devinarayanan
700 views24 slides
Elevate your Career on Clouds | Salesforce Developer Group by
Elevate your Career on Clouds | Salesforce Developer GroupElevate your Career on Clouds | Salesforce Developer Group
Elevate your Career on Clouds | Salesforce Developer GroupShivanath Devinarayanan
512 views9 slides
Salesforce Spring '14 Feature Overview by
Salesforce Spring '14 Feature Overview Salesforce Spring '14 Feature Overview
Salesforce Spring '14 Feature Overview Shivanath Devinarayanan
1.1K views14 slides

Recently uploaded

Business Analyst Series 2023 - Week 4 Session 8 by
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8DianaGray10
180 views13 slides
Cocktail of Environments. How to Mix Test and Development Environments and St... by
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...Aleksandr Tarasov
26 views135 slides
Transcript: Redefining the book supply chain: A glimpse into the future - Tec... by
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...BookNet Canada
43 views16 slides
The Power of Heat Decarbonisation Plans in the Built Environment by
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built EnvironmentIES VE
85 views20 slides
LLMs in Production: Tooling, Process, and Team Structure by
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team StructureAggregage
65 views77 slides
Telenity Solutions Brief by
Telenity Solutions BriefTelenity Solutions Brief
Telenity Solutions BriefMustafa Kuğu
14 views10 slides

Recently uploaded(20)

Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10180 views
Cocktail of Environments. How to Mix Test and Development Environments and St... by Aleksandr Tarasov
Cocktail of Environments. How to Mix Test and Development Environments and St...Cocktail of Environments. How to Mix Test and Development Environments and St...
Cocktail of Environments. How to Mix Test and Development Environments and St...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec... by BookNet Canada
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
Transcript: Redefining the book supply chain: A glimpse into the future - Tec...
BookNet Canada43 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE85 views
LLMs in Production: Tooling, Process, and Team Structure by Aggregage
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team Structure
Aggregage65 views
Discover Aura Workshop (12.5.23).pdf by Neo4j
Discover Aura Workshop (12.5.23).pdfDiscover Aura Workshop (12.5.23).pdf
Discover Aura Workshop (12.5.23).pdf
Neo4j20 views
This talk was not generated with ChatGPT: how AI is changing science by Elena Simperl
This talk was not generated with ChatGPT: how AI is changing scienceThis talk was not generated with ChatGPT: how AI is changing science
This talk was not generated with ChatGPT: how AI is changing science
Elena Simperl34 views
The Coming AI Tsunami.pptx by johnhandby
The Coming AI Tsunami.pptxThe Coming AI Tsunami.pptx
The Coming AI Tsunami.pptx
johnhandby14 views
Innovation & Entrepreneurship strategies in Dairy Industry by PervaizDar1
Innovation & Entrepreneurship strategies in Dairy IndustryInnovation & Entrepreneurship strategies in Dairy Industry
Innovation & Entrepreneurship strategies in Dairy Industry
PervaizDar139 views
GDSC GLAU Info Session.pptx by gauriverrma4
GDSC GLAU Info Session.pptxGDSC GLAU Info Session.pptx
GDSC GLAU Info Session.pptx
gauriverrma415 views
Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty66 views
NTGapps NTG LowCode Platform by Mustafa Kuğu
NTGapps NTG LowCode Platform NTGapps NTG LowCode Platform
NTGapps NTG LowCode Platform
Mustafa Kuğu474 views
"Node.js Development in 2024: trends and tools", Nikita Galkin by Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays37 views
Adopting Karpenter for Cost and Simplicity at Grafana Labs.pdf by MichaelOLeary82
Adopting Karpenter for Cost and Simplicity at Grafana Labs.pdfAdopting Karpenter for Cost and Simplicity at Grafana Labs.pdf
Adopting Karpenter for Cost and Simplicity at Grafana Labs.pdf
MichaelOLeary8213 views
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023 by BookNet Canada
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
Redefining the book supply chain: A glimpse into the future - Tech Forum 2023
BookNet Canada46 views
What is Authentication Active Directory_.pptx by HeenaMehta35
What is Authentication Active Directory_.pptxWhat is Authentication Active Directory_.pptx
What is Authentication Active Directory_.pptx
HeenaMehta3515 views

Governor limits

  • 1. In depth view of the governor limits in apex SalesForce SHIVANATH.D
  • 2. What are Governor Limits ? • Runtime limits enforced by apex • Ensures no monopoly in resources. Memory • Similar to heap size in Java. • Back bone of MULTI-TENANT architecture. Database Resources • The Organization Shares the limit No of Script Statements No of Records processed
  • 3. How are Governor Limits Calculated? There are a number of factors that determine what governor limit is used, and when it is applied Invocation of Apex-Entry How Many Records Which Governor Limit
  • 4. Entry Point • Governor limits are applied based on the entry point Apex Trigger •insert, update, delete, merge, upsert, and undelete are the Trigger Apex Web service operations • All Apex triggers are bulk triggers. • Batch of up to 200 records Anonymous Block • Anonymous block does not get stored in the metadata Visualforce Controller •Run Tests is a Force.com Web Services API call used to execute test methods Run Tests
  • 5. Governor Limit Scope • Governor Limits are shared by the organization Maximum of 100 SOQL Queries •From beginning till end of execution Max of 50,000rows retrieved •Governor limits are not specified for each separate trigger. Max of 200,000 scripts executed •Any Apex class, method, or trigger invoked by code executed within the Max 50 million Batch SOQL entry point will count towards the same governor limits as it's a Batches of up to 2,000 records synchronous request
  • 6. Synchronous vsAsynchronous Apex • Normal Execution Synchronous •@future is asynchronous Synchronous •Business Logic is offloaded •Efficiency increases • but , more callouts VS Asynchronous
  • 8. Limits SOQL statements issued in a request. Database.countQuery Database.getQueryLocator Database.query DML queries issued in a request. Approval.process Database.convertLead Database.emptyRecycleBin Database.rollback Database.setSavePoint delete and Database.delete insert and Database.insert merge undelete and Database.undelete update and Database.update upsert and Database.upsert System.runAs
  • 9. Bulkify your Code Poorly Written Code Bulkified Code
  • 10. Avoid SOQL Queries inside FOR Loops
  • 11. Avoid SOQL Queries inside FOR Loops
  • 13. Streamlining Multiple Triggers on the Same Object • Merge if triggers are redundant • Triggers same share limit • Easy to hit the governor limits
  • 16. Q &A