Is there any difference in performance with Like'%abc' and Like 'abc%'? For example, if I write

List<Account> acc = [SELECT Id from account where name like'abc%'];
List<Account> acc1 = [SELECT Id from account where name like'%abc'];
  • 3
    They both return completely different query results, one is starts with other is ends with wild card search. Performance of both would be different based on the record set. – Raul Jan 16 '18 at 13:53

The only difference in performance I know is when the field is indexed. The standard field Name is indexed by default.

In this document, you can see that for the operation LIKE, Force.com tests for conditions that don't start with a leading wildcard the first 100,000 rows for selectivity.

We can say that, in certain cases, your first query having like'abc%' can be more performant than like'%abc'

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.