It’s important once you have you application up and running that you also ensure it is performant – but what does performant mean? Fast? Scalable? Within Governor Limits? How about all of these and then some! In this session we will go through what is meant by performance, how to measure the performance of your code and understand where time is being used within a transaction as well as the actions to take and some best practices to keep things running nicely.
What do we mean by performance?
Resource usage/code performance
- Using the minimum amount of resources possible
- CPU Statements/Time
- Heap Size
- Using the most efficient mechanism
- Theoretically should make us more performant
Governor Limits vs Performance
|Stop us from monopolising resources||How to improve the way in which our code runs and uses resources|
|Hard limits||No limit but rather an optimization goal|
|Avoidance rather than a target•55 SOQL Queries vs 90 SOQL Queries|
User Perceived Performance
- What does the user actually experience?
- CPU Time vs Heap Size
- Perception vs reality
- UX vs Technical Improvements
- This is what the user will care about but may not align with Governor Limits etc.
Handling a greater volume of data and users
How do we measure performance?
Using Governor Limits
- Governors ≠ Performance
- Act a very useful guide for what we should be focusing on
- Should measure against limits during testing
- A Limit Exceptions the worst exception to get
- Salesforce provides a Limits class to allow us to take measurements on how resources are being used
- Measure both usage and against total available limit
- Schrodinger’s Cat issues -taking a measurement can impact the measurement
- A primary source of CPU time consumption
- Nested loops can quickly consume resources
- Ensure you follow best practices
- No DML in loops
- No SOQL in loops
- Avoid expensive operations in loops
- Different loop options have impacts
Heap Size Results
How to Improve SOQL Performance
- Run fewer queries
- Cache results in memory to reuse them wherever possible
- Ensure that your queries are selective
- Indexed filters
- Implement strict sharing
- Limits on queries
Caching and the Platform Cache
Asynchronicity and Architecture
- What do we mean by performance?
- How do we measure performance?
- Loop Performance
- SOQL Performance
- Asynchronicity and Architecture
Amit Chaudhary is Salesforce Application & System Architect and working on Salesforce Platform since 2010. He is Salesforce MVP since 2017 and have 17 Salesforce Certificates.
He is a active blogger and founder of Apex Hours.