Salesforce: Index Fields
In the modern cloud application with a large data set like Salesforce, indexing is very important to allow an application to search and return results to users at a minimum time and cost. Indexing will also be used by query optimizer to gather the statistics of each index. This will then be utilized as part of the pre-query process to determine whether an index would speed up the query.
There are 2 types of indexes in Salesforce:
- Standard Index
- Custom Index
Salesforce maintains indexes on the following fields for most objects:
- Systemmodstamp (LastModifiedDate)
- Email (for contacts and leads)
- Lookups and master-detail relationship
- Salesforce record ID
Salesforce administrator can define a custom index field by making the field as “External ID” or unique field for the following field types:
You can only have up to 3 external ID/unique Fields in an object as it doesn’t make sense if you make a field as external ID/unique just for the sake of getting it to be indexed by Salesforce. Fortunately, you can request Salesforce Support to create a custom index for deterministic fields.
Please note: That if you have created a custom index for a formula field, the index will be removed if you modified the formula field. You will have to request Salesforce support to re-enable it.