Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Bind variable and the "like" operator
No, the use of a bind variable in the like does not force the CBO to
always perform a full table scan instead of use the index, if one is
available. That decision depends on the statistics for the indexed
columns, other where clause conditions, and the usual factors that
influence the optimizer.
> EXPLAIN PLAN SET statement_id = 'mpowel01' FOR 2 -- Insert sql after this line. WARNING - Do not end sql in ';'
3 select item_no 4 from item_master 5 where item_no like :var||'%'
Explained.
> rem
> set echo off
QUERY_PLAN
COST CARDINALITY