从我所有的搜索到加速sql server中的查询,源代表说通过使用正确的where子句来减少逻辑读取.实际上我需要知道如果从前端获得请求时sql server中的存储过程如何工作流程,以及在存储过程中避免的一些提示.
我正在尝试加快我的存储过程,所以我使用下面的统计信息以两种格式测试我的存储过程
方法1:使用join
set statistics io on
select top 2000
p.Vehicleno,
dbo.GetVehicleStatusIcon1(p.Direction, StatusCode, 0) as 'Status',
location,
Convert(varchar(13), p.TrackTime, 102) + ' ' + Convert(varchar(13), p.TrackTime, 108) AS 'TrackTime',
p.Speed, p.Ignition
from
pollingdata p
inner join
assignvehicletouser asn on asn.vehicleno = p.vehicleno
where
asn.empid = 1
Run Code Online (Sandbox Code Playgroud)
我得到统计结果为
Table 'Worktable'. Scan count 943, logical reads 7671, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'AssignVehicleToUser'. Scan count 1, logical reads 41, …
Run Code Online (Sandbox Code Playgroud) sql-server join where-clause logical-reads sql-execution-plan