I have taken over a legacy application that has had many performance issues. One I found is on a table valued function.
The TVF runs fine as a basic
SELECT. However, it is incredibly slow when it has a
WHERE clause on it.
I would have thought that the
WHERE filter is applied after the TVF query has run?
I don't understand how the
WHERE clause can have such an impact on performance.
The query is:
select * from tvf(@id, @name) where id = @id