Two-Column Custom Indexes in Salesforce

Two-Column Custom Indexes in Salesforce

Two-column custom indexes are a specialized feature of the Salesforce platform. They are useful for list views and situations where you want to use one field to select records to display and another field to sort them. 
 
For example
1. An Account list view that selects by State and sorts by City can use a two-column index with State in the first column and City in the second.

2. When a combination of two fields is a common filter in the query string, two-column indexes typically help you sort and display records.

For example, for the following SOQL, which appears in pseudo code, a two-column index on f1__c,f2__c is more efficient than single indexes on f1__c and f2__c.

SELECT Name
FROM Account
WHERE f1__c = ‘foo’
AND f2__c = ‘bar’

Note: 
Two-column indexes are subject to the same restrictions as single-column indexes, with one exception. Two-column indexes can have nulls in the second column by default.

Leave a Reply