39

I'm trying to find a proper list of what standard fields are indexed by default in salesforce, as well as under what conditions custom fields are indexed.

To start things off I know fields are indexed:

  • When salesforce has added a custom index at your request (but you can't rely on this in other orgs)
  • Any fields marked as external IDs
  • Master-Detail fields
  • Lookup fields
  • System audit fields (CreatedDate, SystemModStamp)

I've asked salesforce support and there is no authoritative documentation on this outside of this page: http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_VLSQ.htm

2
  • Would you consider the Id field as being indexed or just the primary key? Probably not what you were looking for. I suspect many of the limits in place are driven by underlying indexes. Such as the number of formula or validation rule references you can have. Commented Aug 8, 2012 at 3:54
  • One omission from your list I can see is the Id field of all objects Commented Aug 8, 2012 at 7:20

3 Answers 3

18

As of the Spring 15 release of Salesforce, the easiest way to see which fields on a given object are indexed is to check for a "check" in the "Indexed" column in the list of an object's fields in Setup:

Indexed Column in Object Fields list

25

From the page you linked

The following fields are indexed by default: primary keys (Id, Name and Owner fields), foreign keys (lookup or master-detail relationship fields), audit dates (such as LastModifiedDate), and custom fields marked as External ID or Unique.

That line answers both the "by default" and "under what conditions custom fields" aspects of your question. That's it.

Update

Some additional information about which fields are automatically indexed and exceptions for those which cannot be indexed is available in the Best Practices for Deployments with Large Data Volumes (PDF) architecture documentation. (In addition to a ton of other great stuff.)

The platform automatically 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, with the exception of multi-select picklists, text area (long), text area (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.

External IDs can be created on only the following fields.

  • Auto Number
  • Email
  • Number
  • Text

To create custom indexes for other field types, including standard fields, contact salesforce.com Customer Support

6
  • 1
    I've heard plenty of back and forth that some standard fields are indexed as well, any idea on if that's true or not? Commented Aug 8, 2012 at 16:05
  • 1
    Beyond what is in the documentation I do not know. Unless there are core Salesforce developers active here not sure we'll get an answer on that. I would take the line that the documentation is correct until such time as a reliable and verifiable source says otherwise. If you need indexes added else where for your org you can always request it. Commented Aug 8, 2012 at 16:14
  • 1
    We've requested indexes on Lead.Email and Lead.Phone standard fields and been denied. Commented Feb 11, 2013 at 0:18
  • 1
    RecordTypeId and Division are also indexed where appropriate. Email is indexed on Contact and Lead.
    – Wes Nolte
    Commented Apr 15, 2013 at 17:11
  • 1
    @ca_peterson, added some additional details to this about the fields which are automatically indexed... if you're still curious about this info two years later!
    – Mark Pond
    Commented Jul 16, 2014 at 20:48
14

Just found that salesforce has posted a cheat sheet with much more data about indexing than I've ever seen before. Take a look at the Query & Search Optimization Fields Cheat Sheet on the developerforce wiki's cheat sheet area.

One big takeaway is that there are some substantial differences between performance of standard and custom indexes.

Fields that have standard index applied:

  • Custom lookup fields
  • Custom master-detail fields
  • Id
  • Name
  • Owner
  • Audit dates
  • On standard objects there are some others that aren't documented anywhere

Custom indexes:

  • Can be added by salesforce support
  • External Id fields
  • Unique fields
3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .