Your queries:
select A from table_A where A like 'A%'
and
select A from table_A where A like 'A%%'
^ optimizer will remove second redundant %
are equivalent, the optimizer will remove the second %
in the second query
just like it would remove the 1=1
from:
select A from table_A where A like 'A%%' and 1=1
However, this query is very different:
select A from table_A where A like '%A%'
The when using 'A%'
it will use the index to find everything starting with an A
, like a person using a phone book would quickly look for the start of a name. However when using '%A%'
it will scan the entire table looking for anything containing an A
, thus slower and no index usage. Like if you had to find every name in the phone book that contained an A, that would take a while!