Custom indexes are database indexes created on custom fields in Salesforce to improve query performance, especially when working with large data volumes. By indexing a field, Salesforce can retrieve records more efficiently when that field is used in filters (such as in SOQL queries, reports, or list views), reducing query time and avoiding performance issues.
Change sets are a Salesforce deployment tool used to move configuration (metadata) from one org to another, typically from a sandbox to a production environment. They allow you to bundle components like objects, fields, flows, Apex classes, and more, and deploy them without using external tools.
There are three main ways to create indexes:
This article explains more details about "Copy existing custom indexes using change sets".
Copying Existing Custom Indexes Using Change Sets
<Reference> Components Available in Change Sets
In an Outbound Change Set, select [Custom Index] (English notation only) from the "Component Type" to add to your Change Set.
=====
Known Issue: Certain types of Custom Indexes are not available in Change Sets
=====
As of July 2023, as stated in the Known Issue article above, not all custom indexes can be copied using change sets. They fall into three categories: 1) those that do not need to be copied, 2) those that can be copied, and 3) those that cannot be copied. See the specific examples below.
1) Indexes That Do Not Need to Be Copied
When you enable either the "Unique" or "External ID" option for a field, an index is automatically created. Since these are automatically generated in every organization, there is no need to copy them yourself using change sets.
| 1st Column | 2nd Column | Change Set Copyability | |
| Automatically created |
Custom Field (with "Unique" and/or "External ID" option(s) enabled) | None | Not Copiable (No need to copy) |
2) Indexes That Can Be Copied Using Change Sets
A single index on a custom field that has neither the "Unique" nor "External ID" options enabled, or a two-column custom index where the first column is a custom field with neither the "Unique" nor "External ID" options enabled, can be copied via change sets regardless of the second column's type.
| 1st Column | 2nd Column | Change Set Copyability | |
| Single Index | Custom Field (neither "Unique" nor "External ID" option) | None | Copiable |
| Two-column Custom Index | Custom Field (neither "Unique" nor "External ID" option) | Standard Field | Copiable |
| Two-column Custom Index | Custom Field (neither "Unique" nor "External ID" option) | Custom Field (neither "Unique" nor "External ID" option) | Copiable |
| Two-column Custom Index | Custom Field (neither "Unique" nor "External ID" option) | Custom Field (with "Unique" and/or "External ID" option(s) enabled) | Copiable |
A two-column custom index where the first column is a custom field with only the "Unique" option enabled can also be copied via change sets, regardless of the second column's type.
| 1st Column | 2nd Column | Change Set Copyability | |
| Two-column Custom Index | Custom Field (with "Unique" option) | Standard Field | Copiable |
| Two-column Custom Index | Custom Field (with "Unique" option) | Custom Field (neither "Unique" nor "External ID" option) | Copiable |
| Two-column Custom Index | Custom Field (with "Unique" option) | Custom Field (with "Unique" and/or "External ID" option(s) enabled) | Copiable |
A two-column custom index where the first column is a custom field with the "External ID" option enabled and the second column is a custom field, can also be copied via change sets.
| Two-column Custom Index | Custom Field (with "External ID" option) | Custom Field (neither "Unique" nor "External ID" option) | Copiable |
| Two-column Custom Index | Custom Field (with "External ID" option) | Custom Field (with "Unique" and/or "External ID" option(s) enabled) | Copiable |
3) Indexes That Cannot Be Copied Using Change Sets
In the following cases, these cannot be copied using change sets. If you need these types of indexes created, you will need to request that Salesforce Support create them.
When deploying custom objects or fields with custom indexes from sandbox to production, indexes must be manually recreated as they don't deploy automatically via Change Sets.
When you create an outbound change set, you select the [Custom Index] component and choose the indexes you want to copy from the list of existing index names. However, these non-copiable index types will not appear in that name list.
| 1st Column | 2nd Column | Change Set Copyability | |
| Single Index | Standard Field | None | Not Copiable |
| Two-column Custom Index | Standard Field | Standard Field | Not Copiable |
| Two-column Custom Index | Standard Field | Custom Field (neither "Unique" nor "External ID" option) | Not Copiable |
| Two-column Custom Index | Standard Field | Custom Field (with "Unique" and/or "External ID" option(s) enabled) | Not Copiable |
| Two-column Custom Index | Custom Field (with "External ID" option) | Standard Field | Not Copiable |
Supplement: Copyability Matrix by Field Option
<Single Index>
**No need to copy, as indexes are automatically created based on the field option.
<Two-column Custom Index>
Related Information:
000395981

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.