Article ID: 163082 - Last Review: March 14, 2006 - Revision: 4.0 FIX: Views Containing a UNION Resolve with Materializing ModelThis article was previously published under Q163082
BUG#: 16522 (6.5)
SYMPTOMS
When you SELECT from a view that contains one or more UNION clauses, the
view is resolved using a materializing model. In other words, the view is
resolved into a worktable first, and then the SELECT statement's
conditional clauses are applied to the intermediate table. This procedure
may have a significant impact on the performance of a query against a view.
WORKAROUND
Avoid using UNIONs inside of views and avoid requiring the use of views for
queries which must span partitioned tables.
STATUS
Microsoft has confirmed this to be a problem in SQL Server 6.5. This problem has been corrected in Service Pack 5a for Microsoft SQL Server 6.5.For more information, click the following article number to view the article in the Microsoft Knowledge Base: 197177
(http://support.microsoft.com/kb/197177/
)
INF: How to Obtain SQL Server 6.5 Service Pack 5a For more information, contact your primary support provider.
MORE INFORMATION
If the view does not contain any UNION clauses, a reformulating model is
used. This means that the conditional expressions in the SELECT statement
outside the view are effectively merged with any conditional expressions
within the view, and applied directly to the underlying table(s) for the
purposes of the query plan. If there are any suitable indexes on the
underlying table, this procedure may result in far fewer pages being
fetched.
For example, consider the following statements:
In the case of the materializing_view, 10,000 rows from TABLE_1 are inserted into an intermediate worktable; another 10,000 rows from TABLE_2 are appended to the worktable; and the worktable is scanned to restrict the result set to the single row desired. No indexes are used because table scans are required. To observe the "showplan" and "statistics I/O" output that results from the behavior described above, use the following script: | Article Translations
|

Back to the top
