Reputation: 8967
SQL Server 2012: I have a stored procedure with a parameter of user-defined table-type.
To create its return rowset, the stored procedure selects from a view joined to the param table on a few columns none of which have indexes (which are problematic to add for other reasons).
Is it better to :
The view can contain up to ~1 million rows.
Is there any advantage either way? Or does SQL Server internally implement both approaches in a similar manner?
Upvotes: 0
Views: 989
Reputation: 43636
I will start with creating temporary table in which to insert the user-defined table type. The defined table-type is practically a table-variable and joining table variables to other objects is pretty slow in some cases because the SQL Engine does not good information about how many rows the table-variable has.
The second thing that can be optimize is the view. The questions here are:
Upvotes: 1