LIKE work-around in SQL (Performance issues)

I've been reading around and found that using LIKE causes a big slowdown in queries.

A workmate recommended we use

Select Name
From mytable
a.Name IN (SELECT Name 
           FROM mytable
           WHERE Name LIKE '%' + ISNULL(@Name, N'') + '%' 
           GROUP BY Name)

in lieu of

Select Name
From mytable
a.Name LIKE '%' + ISNULL(@Name, N'') + '%'

Now I'm no SQL expert and I don't really understand the inner workings of these statements. Is this a better option worth the effort of typing a few extra characters with each like statement? Is there an even better (and easier to type) alternative?

6
задан Jonn 11 September 2010 в 23:53
поделиться