Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A view is a macro that is expanded into the outer query. Unless it's an indexed view and you have enterprise edition, it's simply ignored.</p> <p>So if you join 3 views and each views uses 5 tables, you have big join with 15 tables.</p> <p>You best bet is the <a href="http://msdn.microsoft.com/en-us/library/ms173494%28SQL.90%29.aspx" rel="nofollow noreferrer">Database Tuning Advisor</a> or a missing index script:</p> <pre><code>SELECT CONVERT(decimal(28, 1), migs.avg_total_user_cost * migs.avg_user_impact * (migs.user_seeks + migs.user_scans)) AS improvement_measure, 'CREATE INDEX missing_index_' + CONVERT(varchar, mig.index_group_handle) + '_' + CONVERT(varchar, mid.index_handle) + ' ON ' + mid.statement + ' (' + ISNULL(mid.equality_columns, '') + CASE WHEN mid.equality_columns IS NOT NULL AND mid.inequality_columns IS NOT NULL THEN ',' ELSE '' END + ISNULL(mid.inequality_columns, '') + ')' + ISNULL(' INCLUDE (' + mid.included_columns + ')', '') AS create_index_statement, migs.*, mid.database_id, mid.[object_id], mig.index_group_handle, mid.index_handle FROM sys.dm_db_missing_index_groups mig INNER JOIN sys.dm_db_missing_index_group_stats migs ON migs.group_handle = mig.index_group_handle INNER JOIN sys.dm_db_missing_index_details mid ON mig.index_handle = mid.index_handle WHERE CONVERT(decimal(28, 1), migs.avg_total_user_cost * migs.avg_user_impact * (migs.user_seeks + migs.user_scans)) &gt; 10 AND database_id = DB_ID() ORDER BY migs.avg_total_user_cost * migs.avg_user_impact * (migs.user_seeks + migs.user_scans) DESC </code></pre> <p>Edit, after example</p> <p>You are nesting views on top of views. No optimisations are possible of the view itself. </p> <p>As mentioned, this can't be indexed</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload