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
Ken Koellner @ EngagewareKen Koellner @ Engageware 

Index used in SOQL query with leading % in Like showplan

There are a number of resources that state that SOQL queries will not use an index when the LIKE operator is used if the value includes a leading "%" (some resources simply say contains "%").

I tried it and it appears to be indexing.  See the example below. I'm using the value "%inc.com%" on the Contact.email field and it is indexed.  

Does anyone knows where UP-TO-DATE documentation is on when SOQL indexes?  Many blogs are out of date.
 

14:38:44.0 (2411702)|SOQL_EXECUTE_BEGIN|[1]|Aggregations:0|SELECT Id FROM Contact WHERE email LIKE '%inc.com%'
14:38:44.0 (51660495)|SOQL_EXECUTE_EXPLAIN|[1]|Index on Contact : [Email], cardinality: 166, sobjectCardinality: 132480, relativeCost 0.071
14:38:44.0 (51677498)|SOQL_EXECUTE_END|[1]|Rows:199

HarshHarsh (Salesforce Developers) 
Hi Ken. 
These two articles are Salesforce help articles, which might be useful to you.
Please refer to the below links.
Please mark it as Best Answer if the above information was helpful.

Thanks.