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'];
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'
starts with
other isends with
wild card search. Performance of both would be different based on the record set.