function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Create an index on a field?

We have a VisualForce page that does a query/look up based on the phone number fields.  This is in a call center, so speed is somewhat important.  We are querying 1.6M records and the query time is longer than we'd like.  Is it possible to create an index on a standard field?  How about on a custom field?  If we set it as an External ID, must it then be unique? 

It is possible to create what's called a "custom index" to do this, but if you're searching phone fields, that's likely not what you want to do here.  When you're searching on phone fields (or name fields, or email fields) you'll want to use the SOSL langauge instead of SOQL to do your queries.  The reasons are:

* It searches all phone fields at once (so no Phone='x' OR MobilePhone='x' OR HomePhone='x' etc.) so it simplifies your query
* It's based on a very fast index

Message Edited by werewolf on 10-16-2008 10:49 AM