Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

In-Line TVF Split Function JOIN to Base Tables Optimization

$
0
0
I have a specific question about JOINing results of an in-line split function to base tablesI am using an in-line TVF and joining to base tables. Sample code below.The problem is the optimizer does not know how many records the TVF returns and so ends up with base table scans and parallelism.If I INSERT the results of the TVP into a table var then JOIN on that table var, all is well b/c the optimizer has a count --- but that defeats the point of an in-line TVF.I did some research on this but am not seeing much discussion.Any ideas much appreciated.SELECT MyBaseTable.KeyColumn ,MyBaseTable.Col1 ,MyBaseTable.Col2FROM MyBaseTable INNER JOIN dbo.fnListToTable8K_InLine(@List,',') ListAsTable ON ListAsTable.ListItem = MyBaseTable.KeyColumn

Viewing all articles
Browse latest Browse all 3145

Trending Articles