Category: Performance

Continuation in Salesforce – Asynchronous Callout option for long running requests

While implementing features, we need to write code to call external web services to fetch or update information. But calling external web service doesn’t mean we should wait for the response from the web service. That is a bad design. We should always write code in such a way so that we can call external web service and still continue to do other work and when the response is available from the web service, we will update the page with response. This way of calling web service is known as Asynchronous callout.Since in Salesforce, we are living in a multi-tenant architecture, so calling external services synchronously can create issues if the response is taking too much of time to come due to network latency or complex calculation or long running requests. There can be n number of reasons why the response is taking longer time. To make sure System resources are available to all customers, Salesforce introduces limitation on how much synchronous callout you can do from a single organization. Limit is each org can make a maximum of 10 synchronous requests running for more than 5 seconds. When the limit is reached, any subsequent request will fail until and unless an existing request completes successfully.Apex continuation is an architectural design which will allow to call long running external web services in a scalable fashion without blocking any server...

Read More

Query Plan Tool from Salesforce – A Hidden Gem

Query Plan in the developer console can help to speed up SOQL queries done over large volumes of data. This is such a powerful tool when dealing with bad performance. Developer can use this tool to optimize and speed up SOQL queries.We can enable Query Plan in the Developer Console by -Before we go into details, it’s better to understand how Salesforce uses indexes while running the SOQL. As we all know it is always good to go for selective query instead of full table scan. But even with selective query, when we are using different filter criteria, it is not always the best SOQL query we are writing. The reason behind is that just writing where clause in the query does not guarantee that the filter is selective. So it is very important to understand which are the fields are good to be used in filter. Let’s understand that first in the below section -All we need to use is the indexes in the filter.If we are using filter on standard fields, then we are using index if -it is primary key (Id, Name, OwnerId)it is a foreign key (CreatedById, LastModifiedById, Lookup, Master-Detail)it is an audit field (CreatedDate, SystemModstamp).If we are using filter on custom fields, then we are using index if that field is marked as Unique or External Id.Without indexed filter, the query will not be...

Read More

LastModifiedDate Vs SystemModStamp

In Salesforce, when we create or update a record, there are so many things happen in the background. In this post, I am going to share my knowledge regarding two important fields present in each Salesforce record. I will start with a basic explanation regarding these fields and then at the end, I will explain how these fields are going to impact your query performance.Nice to check out: Salesforce Spring 21 Release FeatureSalesforce Certification NotesSalesforce Release Video TutorialsSalesforce Lightning Flow Video TutorialsLet’s start with basic explanation -LastModifiedDate:This is a standard field present in each Salesforce record. This field will be updated with current timestamp when the record is created or edited by Salesforce user. This field also has a very unique feature i.e. this field can be imported with some previous date. Let’s say you want to load data from your old legacy system, but you want to preserve the dates from your legacy system. In this situation, you can load the records from your legacy system into Salesforce by updating the LastModifiedDate field with the previous date.SystemModStamp:This is a read-only field. This field will be updated with current timestamp when the record is updated by the user. But the important difference is that this field will also be updated when the record is updated by Automated System Process. So in mathematical term -LastModifiedDate <= SystemModStamp    This is possible.LastModifiedDate > SystemModStamp ...

Read More
Loading

Earlier Posts

  • 2024 (19)
  • 2023 (47)
  • 2022 (25)
  • 2021 (35)
  • 2020 (41)
  • 2019 (13)
  • 2018 (16)
  • 2017 (14)
  • 2016 (18)
  • 2015 (74)
  • 2014 (20)