我正在对性能不佳的存储过程的点点滴滴进行故障排除。程序的这一部分抛出了一个 NO JOIN PREDICATE 警告
select
method =
case methoddescription
when 'blah' then 'Ethylene Oxide'
when NULL then 'N/A'
else methoddescription
end,
testmethod =
case methoddescription
when 'blah' then 'Biological Indicators'
when NULL then 'N/A'
else 'Dosimeter Reports'
end,
result =
case when l.res is null or l.res <> 1 then 'Failed'
else 'Passed'
end,
datecomplete = COALESCE(CONVERT(varchar(10), NULL, 101),'N/A')
from db2.dbo.view ls
join db1.dbo.table l
on ls.id = l.id
where item = '19003'
and l.id = '732820'
Run Code Online (Sandbox Code Playgroud)
视图 ( …
很像swasheck 的一个相关问题,我有一个历史上曾遭受性能问题的查询。我正在查看 SSMS 上的查询计划并注意到Nested Loops (Inner Join)警告:
无连接谓词
根据一些仓促的研究(鼓舞人心的DBA和Brent Ozar 的信心),看起来这个警告告诉我我的查询中有一个隐藏的笛卡尔积。我已经检查了几次我的查询,但没有看到交叉连接。这是查询:
DECLARE @UserId INT; -- Stored procedure input
DECLARE @Now DATETIME2(7) = SYSUTCDATETIME();
;WITH AggregateStepData_CTE AS -- Considering converting this CTE into an indexed view
(
SELECT
[UA].[UserId] -- FK to the UserId
, [UA].[DeviceId] -- FK to the push device's DeviceId (int)
, SUM(ISNULL([UA].[LatestSteps], 0)) AS [Steps]
FROM [User].[UserStatus] [UA]
INNER JOIN [User].[CurrentConnections] [M] ON
[M].[Monitored] = [UA].[UserId] AND …Run Code Online (Sandbox Code Playgroud) performance join sql-server azure-sql-database query-performance