开发者

Query Optimization Question

开发者 https://www.devze.com 2023-01-15 01:48 出处:网络
Assume I have the following query: Update LPMBonusReport Set BoxID = (Select ContainerSerialNumber From Wip.vwWorkItem Where SerialNumber = LPMBonusReport.SubID)

Assume I have the following query:

Update LPMBonusReport Set BoxID = (Select ContainerSerialNumber 
       From Wip.vwWorkItem Where SerialNumber = LPMBonusReport.SubID)

The object Wip.vwWorkItem is a view.

Assume there are 100 rows in the LPMBonusReport table. Would the view get materialized 100 times, once for each row in LPMBonusReport, or would i开发者_开发问答t get materialized just once?

Thanks.


The optimizer would build a (single) execution plan based on LPMBonsReport and the tables comprising the view. Run and review your query in an SSMS query window with "Include Actual Execution Plan" on (it's an option in the "Query" menu.)


I'd prefer to eliminate the subquery and see this written as:

Update BR
    Set BoxID = WI.ContainerSerialNumber
    from LPMBonusReport BR
        inner join Wip.vwWorkItem WI
            on BR.SubID = WI.SerialNumber 
0

精彩评论

暂无评论...
验证码 换一张
取 消