37

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

  • 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. – Daniel Ballinger Aug 8 '12 at 3:54
  • One omission from your list I can see is the Id field of all objects – Daniel Blackhall Aug 8 '12 at 7:20
14

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

23

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

  • 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? – ca_peterson Aug 8 '12 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. – David Gillen Aug 8 '12 at 16:14
  • 1
    We've requested indexes on Lead.Email and Lead.Phone standard fields and been denied. – Steven Herod Feb 11 '13 at 0:18
  • 1
    RecordTypeId and Division are also indexed where appropriate. Email is indexed on Contact and Lead. – Wes Nolte Apr 15 '13 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 Jul 16 '14 at 20:48
13

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.