Performance Optimization Techniques for Salesforce CRM_ Indexing, Query Optimization, and Data Partitioning

When we talk about the deployment of large volumes of data, we also need to know that it takes huge storage as well. As it scales, the operation time needs to be optimized to a certain level, otherwise, at this stage, the way we deal with data can cause hindrances in the day-to-day process.

In this article, let’s understand how to optimize the Salesforce CRM implementation Services for performance.


To retrieve data records faster, you can create database indexing to locate the things you are finding effectively. Why would you index generally?

  1. To aggregate data.
  2. Effectively using the join feature
  3. In correlating data across other tables
  4. Data sorting to arrive at an answer for a query
  5. To locate the rows in columns by values

When the data set is large, scanning wouldn’t be helpful. Currently, the multitenant architecture in Salesforce doesn’t support indexing the table for custom fields.

However, it can create an index table that is a copy of the data along with the data types. On the index table, Salesforce creates a standard database index. With an upper limit on the number of records in the index table, the index search can now effectively return a value.

The null value by default isn’t indexed by the index table, to index such custom fields, support can help. These values need to be explicitly called and built to be indexed.

For frequently queried fields and selective queries consider using the custom indexes for effective data retrieval from the records.

Query Optimization

To analyze the SOQL queries, Salesforce offers a query planning tool available in the developer console, using which you can speed up the process for large volumes of data.

For any SOQL query that is running slowly, you can use this tool to check the query plan. It will provide you with all the plans and their insights, whether some filters need to be indexed, or the cost of the full table scan or indexing plan.

You can create a filter to be selective so that only what’s necessary will get scanned. The query optimizer doesn’t consider a non-selective filter to be queried.

For a query optimizer, the filter can either be composite or simple. The field expression with the OR operation is composite whereas the AND operation is simple. Firstly, the filter must be indexed. If so, for a standard field, if they are primary key, audit field, or foreign key, it’ll have an index. For a custom field, if marked as an external field or unique, it’ll be indexed. If it isn’t indexed, it can’t be optimized. Also, you need to check for the threshold and selectivity threshold of the records for both standard and custom fields, which are set with a limit. Beyond the threshold, the query optimizer can’t optimize.

By using both selective SOQL queries and custom indexes, the performance can be improved.

Data Partitioning

Large data sets can be divided using partitioning, which will allow the queries to reduce the number of records they will return.

The partitions created here will be stored on a different server and hence, they are queried among different servers, which improves the performance.

Suppose, in a deployment on partitioning the data set based on location, the large data sets now get divided into smaller groups that may not have a larger interrelationship with each other.

While that’s just an example, Salesforce has special support who could help you create a division of a large data set by contacting the support.

Mashups to optimize

There is a way to reduce the dataset and it is by maintaining the data in the different applications, which will later allow Salesforce to access it. That’s nothing but a mashup, as it is an integration of two applications. Both externally hosted and internally hosted data can be presented using a Salesforce presentation.

The mashup in Salesforce can be called in two ways: 

1.  Callouts

In real-time, to exchange information, web services can be used by Salesforce, as the apex code allows them to do so.

2.  External website

The UI of Salesforce can request and pass information to an external website, which makes it look as if the website is a part of Salesforce.

This method has limitations in doing so for small datasets and smaller interactions.

SOSL and SOQL utilization

To perform a text-based search, SOSL queries can be used. The effective way to find a date when you are unsure whether in which field or object it resides then is the way. Run this on receiving data from a division and in receiving data from multiple fields and objects, though they may be unrelated.

Whereas for performing SQL select statement-like approach SOQL can be used. When you exactly know where to find the data. If you want to retrieve data from multiple or single objects that are related. If you are retrieving from multiple dates, several checkbox fields are. In counting the records that match specific criteria and sorting the data as part of a query.

Optimization with Delete

When the user deletes the data, the data is flagged as deleted and goes into the recycle bin, which is a soft deletion until it is hard deleted after 15 days in the recycle bin. When it is in soft deletion, the data is still visible in the database, so only until it is hard deleted the performance can be optimized.

The technique of deferred sharing calculation

Suppose you are adding new sharing rules, modifying them, adding new users, or changing any content. This may cause performance issues or timeouts. Deferring sharing calculations come into play at this time.

So when making configuration changes, the administrator of the organization can process the changes during working hours. To recalculate the changes, they can resume it during the weekends.

The Wrap

Dealing with the deployment of large volumes of data is a serious consideration as it can affect the performance of the CRM due to the longer querying time. These are a few of the techniques that can significantly help in improving Salesforce CRM performance.