This could be because '=' can use an index but LIKE cannot. If
the column that is part of the '=' expression ("columnname" in 
your example) has an index, and contains many rows with the
same value (i.e 'abcd'), then using the index will be slower 
than the linear table scan forced by LIKE.

In general, if your query will return a significant percentage
of the rows in your table (say 25%), you want to avoid using an
index. The LIKE syntax does this. So does:

select * from table where (columnname || '') = 'abcd'

and you won't have any problem with % or _ charcters.


--- R S <[EMAIL PROTECTED]> wrote:

> Hi,
> I tried using LIKE instead of = on a varchar column and found the results 
> astonishingly quick?
> 
> select * from table where columnname LIKE 'abcd'
> is far quicker than
> select * from table where columnname = 'abcd'
> 
> Is this true?
> Thanks
> 



                
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

Reply via email to