Query and search optimization
As we explored in Chapter 6, Understanding Large Data Volumes, consider that Salesforce performs searches in a two-part process. The first part is the creation of a result set that is used to then perform the actual search. Let’s quickly remind ourselves how a result set is produced. When a search is invoked (be it through the Salesforce user interface, a Salesforce API, or Apex code), Salesforce will first search the indexes that have been created for the appropriate records. Taking those results, Salesforce will then apply access permissions, search limits, and any other filters or filter logic to narrow down the results into a result set. That result set is then used to perform an actual search for records in the underlying database.
The way to speed up searches is to think carefully about the indexing of fields that are used when searching in order to speed up the performance of those searches. As seen in Chapter 6, Understanding Large Data...