我有一个很大的查询要调整。我写了很多查询,但没有做很多调整。我已经包含了 SQL Sentry Plan Explorer Free (SSPEF) 的屏幕截图:
在计划的上述部分中,表 pb_WorkRquestLog 包含 229,001 行。但是,查询计划显示大约。3.48 亿行(229,001 x 1,520 次迭代):
没有 where 子句,因此查询使用的是聚集索引扫描。我已经用 FULLSCAN 重建了所有索引并更新了所有统计信息。
这部分计划正在执行的代码是:
select distinct
wrs.ServiceKey
, owner.DepartmentName AS GroupName
, owner.UserName AS UserId
, owner.WRLCreateDateTime
, owner.WRLNotes
, wrx.CreatedDate as WRCreateDateTime
, wrx.Id
, wrx.Description
, cast(wrx.Notes as varchar(2500)) as Notes
from
prism72ext.dbo.pb_WorkRequestService wrs
Join prism72ext.dbo.pb_WorkRequest wrx on (wrs.WorkRequestId = wrx.Id and wrx.Status = 'Incomplete')
left join (
select
wl.WorkRequestId
, d.Name AS DepartmentName
, u.UserName
, wl.CreatedDate as …
Run Code Online (Sandbox Code Playgroud) performance sql-server-2005 execution-plan query-performance performance-tuning
performance ×1