我将SQL Server从2016年升级到2019年,我的查询的查询计划改变了,它使用了自适应连接,但不幸的是查询的持续时间从1秒增加到1分钟,我改变了连接顺序,问题解决了
T-SQL 代码:
SELECT TOP 100 * FROM dbo.APP App
JOIN dbo.PRS p ON App.PartyId=p.PRSId
LEFT JOIN dbo.Country ON p.NationalityId = dbo.Country.CountryId
LEFT JOIN dbo.EDUBranch b ON app.EducationBranchId=b.EDUBranchId
Run Code Online (Sandbox Code Playgroud)
它的查询计划:https : //www.brentozar.com/pastetheplan/?id=H1cFQxwdP
更改连接顺序后:
SELECT TOP 100 * FROM dbo.APP App
LEFT JOIN dbo.EDUBranch b ON app.EducationBranchId=b.EDUBranchId
JOIN dbo.PRS p ON App.PartyId=p.PRSId
LEFT JOIN dbo.Country ON p.NationalityId = dbo.Country.CountryId
Run Code Online (Sandbox Code Playgroud)
它的查询计划:https : //www.brentozar.com/pastetheplan/?id=SJv1GlPdv
有没有人知道