【发布时间】:2011-02-13 16:34:16
【问题描述】:
我已经为我的项目创建了视图。现在我想优化它们以提高速度...如何确定视图可以优化?索引对此有用吗?
让我们说下面的例子......
SELECT dbo.vw_WebInventory.skref AS SaleID, dbo.vw_WebInventory.lot_number AS LotNumber, dbo.vw_WebInventory.Description,
dbo.vw_WebInventory.Image AS HasImage, dbo.vw_WebInventory.Sold, dbo.vw_WebInventory.Withdrawn, dbo.vw_WebTopBids.TopBid,
ISNULL(dbo.vw_WebInventory.Mins_Extend_y, 0) AS BidTimeExtend, dbo.Sale.SaleTypeID, dbo.Sale.ClosingDate, dbo.vw_WebInventory.ExDate,
dbo.vw_WebInventory.CurrDate, CASE WHEN vw_WebInventory.ExDate > ISNULL(vw_WebInventory.LotClosingDate, Sale.ClosingDate)
THEN 1 ELSE 0 END AS ShowBidMessage
FROM dbo.vw_WebInventory INNER JOIN
dbo.Sale ON dbo.vw_WebInventory.skref = dbo.Sale.SaleID LEFT OUTER JOIN
dbo.vw_WebTopBids ON dbo.vw_WebInventory.skref = dbo.vw_WebTopBids.CatNumber AND dbo.vw_WebInventory.lot_number = dbo.vw_WebTopBids.LotNumber
其中vm_webTopBids 和vm_WebInventory 是两个不同的视图...
是否可以优化此视图?
【问题讨论】:
标签: sql performance tsql view sql-server-2005