SlideShare a Scribd company logo
1 of 16
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
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

More Related Content

What's hot

Introduction to apex code
Introduction to apex codeIntroduction to apex code
Introduction to apex code
EdwinOstos
 

What's hot (20)

Salesforce REST API
Salesforce  REST API Salesforce  REST API
Salesforce REST API
 
SOQL & SOSL for Admins
SOQL & SOSL for AdminsSOQL & SOSL for Admins
SOQL & SOSL for Admins
 
SOQL in salesforce || Salesforce Object Query Language || Salesforce
SOQL in salesforce || Salesforce Object Query Language || SalesforceSOQL in salesforce || Salesforce Object Query Language || Salesforce
SOQL in salesforce || Salesforce Object Query Language || Salesforce
 
Introduction to apex code
Introduction to apex codeIntroduction to apex code
Introduction to apex code
 
Asynchronous apex
Asynchronous apexAsynchronous apex
Asynchronous apex
 
Apex Trigger in Salesforce
Apex Trigger in SalesforceApex Trigger in Salesforce
Apex Trigger in Salesforce
 
Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex! Dive Deep into Apex: Advanced Apex!
Dive Deep into Apex: Advanced Apex!
 
Triggers and order of execution1
Triggers and order of execution1Triggers and order of execution1
Triggers and order of execution1
 
Integrating with salesforce
Integrating with salesforceIntegrating with salesforce
Integrating with salesforce
 
Episode 6 - DML, Transaction and Error handling in Salesforce
Episode 6 - DML, Transaction and Error handling in SalesforceEpisode 6 - DML, Transaction and Error handling in Salesforce
Episode 6 - DML, Transaction and Error handling in Salesforce
 
Introduction to Apex Triggers
Introduction to Apex TriggersIntroduction to Apex Triggers
Introduction to Apex Triggers
 
Apex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard ProblemsApex Trigger Debugging: Solving the Hard Problems
Apex Trigger Debugging: Solving the Hard Problems
 
SFDC Batch Apex
SFDC Batch ApexSFDC Batch Apex
SFDC Batch Apex
 
Building strong foundations apex enterprise patterns
Building strong foundations apex enterprise patternsBuilding strong foundations apex enterprise patterns
Building strong foundations apex enterprise patterns
 
Salesforce Basic Development
Salesforce Basic DevelopmentSalesforce Basic Development
Salesforce Basic Development
 
Exploring the Salesforce REST API
Exploring the Salesforce REST APIExploring the Salesforce REST API
Exploring the Salesforce REST API
 
Managing Your Batch and Scheduled Apex Processes with Relax
Managing Your Batch and Scheduled Apex Processes with RelaxManaging Your Batch and Scheduled Apex Processes with Relax
Managing Your Batch and Scheduled Apex Processes with Relax
 
Apex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong FoundationsApex Enterprise Patterns: Building Strong Foundations
Apex Enterprise Patterns: Building Strong Foundations
 
LWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura InteroperabilityLWC Episode 3- Component Communication and Aura Interoperability
LWC Episode 3- Component Communication and Aura Interoperability
 
Asynchronous Apex Salesforce World Tour Paris 2015
Asynchronous Apex Salesforce World Tour Paris 2015Asynchronous Apex Salesforce World Tour Paris 2015
Asynchronous Apex Salesforce World Tour Paris 2015
 

Similar to Governor limits

Salesforce app limits_cheatsheet latest by 25 oct 2019
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 Hait
 
Dealing with and learning from the sandbox
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandbox
Elaine Van Bergen
 
DOES SFO 2016 - Avan Mathur - Planning for Huge Scale
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 Kim
 
Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWS Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWS
Tom Laszewski
 

Similar to Governor limits (20)

Introduction to weblogic
Introduction to weblogicIntroduction to weblogic
Introduction to weblogic
 
Salesforce app limits_cheatsheet latest by 25 oct 2019
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
 
Dealing with and learning from the sandbox
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandbox
 
Dealing with and learning from the sandbox
Dealing with and learning from the sandboxDealing with and learning from the sandbox
Dealing with and learning from the sandbox
 
4. (mjk) extreme performance 2
4. (mjk) extreme performance 24. (mjk) extreme performance 2
4. (mjk) extreme performance 2
 
AWS Kinesis - Streams, Firehose, Analytics
AWS Kinesis - Streams, Firehose, AnalyticsAWS Kinesis - Streams, Firehose, Analytics
AWS Kinesis - Streams, Firehose, Analytics
 
ENT309 scaling up to your first 10 million users
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
 
ENT309 Scaling Up to Your First 10 Million Users
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
 
ENT309 Scaling Up to Your First 10 Million Users
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
 
eCAP Developer Walkthru
eCAP Developer WalkthrueCAP Developer Walkthru
eCAP Developer Walkthru
 
Server Day 2009: Oracle/Bea Fusion Middleware by Paolo Ramasso
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
 
DOES SFO 2016 - Avan Mathur - Planning for Huge Scale
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
 
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...
Oleksandr Khotemskyi - Serverless architecture and how to apply it in Automa...
 
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
Олександр Хотемський:”Serverless архітектура та її застосування в автоматизац...
 
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
Cost Effectively Run Multiple Oracle Database Copies at Scale
 
DevDay: Corda Enterprise: Journey to 1000 TPS per node, Rick Parker
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
 
ENT309 Scaling Up to Your First 10 Million Users
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)
Prometheus lightning talk (Devops Dublin March 2015)Prometheus lightning talk (Devops Dublin March 2015)
Prometheus lightning talk (Devops Dublin March 2015)
 
Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWS Migrating enterprise workloads to AWS
Migrating enterprise workloads to AWS
 
Stream Computing (The Engineer's Perspective)
Stream Computing (The Engineer's Perspective)Stream Computing (The Engineer's Perspective)
Stream Computing (The Engineer's Perspective)
 

More from Shivanath Devinarayanan

More from Shivanath Devinarayanan (9)

Salesforce Lightning workshop
Salesforce Lightning workshopSalesforce Lightning workshop
Salesforce Lightning workshop
 
Force.com Friday - Intro to Force.com
Force.com Friday -  Intro to Force.comForce.com Friday -  Intro to Force.com
Force.com Friday - Intro to Force.com
 
Salesforce_Certified_Administrator
Salesforce_Certified_AdministratorSalesforce_Certified_Administrator
Salesforce_Certified_Administrator
 
Force.com Friday - Intro to Visualforce
Force.com Friday - Intro to VisualforceForce.com Friday - Intro to Visualforce
Force.com Friday - Intro to Visualforce
 
Elevate your Career on Clouds | Salesforce Developer Group
Elevate your Career on Clouds | Salesforce Developer GroupElevate your Career on Clouds | Salesforce Developer Group
Elevate your Career on Clouds | Salesforce Developer Group
 
Salesforce Spring '14 Feature Overview
Salesforce Spring '14 Feature Overview Salesforce Spring '14 Feature Overview
Salesforce Spring '14 Feature Overview
 
Salesforce Trivia - Gurgaon User Group
Salesforce Trivia - Gurgaon User GroupSalesforce Trivia - Gurgaon User Group
Salesforce Trivia - Gurgaon User Group
 
Mobile Packs From Salesforce.com
Mobile Packs From Salesforce.comMobile Packs From Salesforce.com
Mobile Packs From Salesforce.com
 
Salesforce Kerala developer user group meetup
Salesforce Kerala developer user group meetupSalesforce Kerala developer user group meetup
Salesforce Kerala developer user group meetup
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

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
  • 7.
  • 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