My query looks like:
SELECT *
FROM dbo.TestTable TT
JOIN dbo.fnListParseAndSplit('test,tt,zz,er,ts',',') L ON TT.Name like '%' + L.ListMember + '%'
My issue is that on the execution plan I always get Index Seek for both cases when joining on:
-
T.Name like ‘%’ + L.ListMember + ‘%’
-
T.Name like L.ListMember + ‘%’.
I was of the opinion that they are completely different and when the join is like ‘%’ + L.ListMember + ‘%’ I should get an index scan.
Do I get something wrong on the execution plan? Or the SQL server 2008 is so smart that it can optimize my query?
I attached the execution plan. Do you know why do I have an index seek on the TestTabe Name column? The name column have an unique index … but in this case I would expect a scan instead of seek.
Index seek is related first part of join, if you look at the posted plan, you’ll see table scan for output of your parse function.