I have a stored procedure using an inline Table Value Function (ITVF) in a data warehouse system. If I copy the code of ITVF to the procedure itself then it makes a lot of performance improvement (from 50 seconds to 9 seconds). I was under impression that ITVF are executed just like the code inside the procedure itself.
I can see there is a huge difference between Actual Rows and Estimated Rows in the query plan when using ITVF.
Is there any possibility of parameter sniffing in ITVF? What else could the reason? Thanks.