Salesforce supports custom indexes to speed up queries, and you can create custom indexes by contacting Salesforce Customer Support.
Note: The custom indexes that Salesforce Customer Support creates in your production environment are copied to all sandboxes that you create from that production environment.
The platform maintains indexes on the following fields for most objects.
• RecordTypeId
• Division
• CreatedDate
• Systemmodstamp (LastModifiedDate)
• Name
• Email (for contacts and leads)
• Foreign key relationships (lookups and master-detail)
• The unique Salesforce record ID, which is the primary key for each object
Salesforce also supports custom indexes on custom fields, except for multi-select picklists, text areas (long), text areas (rich), non-deterministic formula fields, and encrypted text fields.
External IDs cause an index to be created on that field, which is then considered by the Force.com query optimizer.
You can create External IDs only on the following fields.
• Auto Number
• Email
• Number
• Text
To create custom indexes for other field types, including standard fields, contact Salesforce Customer Support.
By default, the index tables do not include records that are null (records with empty values). You can work with Salesforce Customer Support to create custom indexes that include null rows. Even if you already have custom indexes on your custom fields, you must explicitly enable and rebuild them to get the empty-value rows indexed.
Two-Column Custom Indexes
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, 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.
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\’