Databases Reference
In-Depth Information
POH.PurchaseOrderID
,POH.OrderDate
,EMP.LoginID
,V.Name AS VendorName
,SUM(POD.OrderQty) AS OrderQty
,SUM(POD.OrderQty*POD.UnitPrice) AS Amount
FROM
[Purchasing].[PurchaseOrderHeader] AS POH
JOIN
[Purchasing].[PurchaseOrderDetail] AS POD
ON
POH.PurchaseOrderID = POD.PurchaseOrderID
JOIN
[HumanResources].[Employee] AS EMP
ON
POH.EmployeeID=EMP.BusinessEntityID
JOIN
[Purchasing].[Vendor] AS V
ON
POH.VendorID=V.BusinessEntityID
GROUP BY
POH.PurchaseOrderID
,POH.OrderDate
,EMP.LoginID
,V.Name
GO
SELECT top 10 * FROM POView WITH (NOEXPAND)
GO
3.
Now, if we review the execution plan, we can see that the execution plan of the
POView view is much better, due to the clustered index we have created on the view.
The first query searches records from the different indexes defined on the table that
comes with the AdventureWorks2012 database, whereas the second query on the
view searches records from the single clustered Index we have created on the view.
 
Search WWH ::




Custom Search