0

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'];
1
  • 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, 2018 at 13:53

1 Answer 1

4

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'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .