Problem with SQL Server

I am using SQL Server 2008 Enterprise. Now I have two templates for implementing the same function (to see if column zoo1 or zoo2 or zoo3 contains any text, in template 1 I combine the contents of zoo1, zoo2 and zoo3 to form a new column called the zoo) I think the first sample always has the best performance (I did some experiment) from my experiment. But I'm not sure how right I am, and what is the internal reason why model 1 always has the best performance?

Sample 1:

Select foo, goo from tablefoo where zoo like LIKE '%'+@Query+'%'

Sample 2 (zoo is the column into which I generated the contents of the column zoo1, zoo2 and zoo3):

Select foo, goo from tablefoo where (zoo1 like LIKE '%'+@Query+'%') OR (zoo2 like LIKE '%'+@Query+'%') or (zoo3 like LIKE '%'+@Query+'%')

thanks in advance George

+3
1

.

3 vs 1 .

, %, ( , zoo%)

1 , 3 . "".

+3

Source: https://habr.com/ru/post/1763946/


All Articles