2017-07-18 191 views
-4

同時檢查活動監視器,我發現了一些昂貴的查詢,併爲執行計劃附在這裏execution plan最近昂貴的查詢

,同時檢查它顯示索引查找是66%,它意味着什麼?它如何變得昂貴的查詢? 有人請幫助

+0

查詢運行了多長時間? –

+0

你正在使用哪個dbms? – jarlh

+0

MS SQL SERVER 2012 .... – Sanal

回答

0

您正在使用2子查詢的結果是更Cosltier,你可以用聯接或臨時表替換你的子查詢。

此外,您還可以索引行程表的VehicleSchedules表和vehicleScheduleid列的SchedStartTime。

注意:索引會影響您的DML查詢。

select top 1 @v_CancelScheduleid= VehicleScheduleid 
from VehicleSchedules WITH (NOLOCK) 
where [email protected]_VehicleId 
and vehicleScheduleid not in (select isnull(vehicleScheduleid,0) from trip WITH (NOLOCK)) and SchedStartTime<(select SchedStartTime from VehicleSchedules WITH (NOLOCK) where [email protected]) order by SchedStartTime desc