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