I upgrade SQL Server from 2016 to 2019, the query plan of my query changed and it used adaptive join, but unfortunately the duration of query increase to 1 minute from 1 second, I changed the join order and the problem was solved
The T-SQL code:
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
and it 's query plan : https://www.brentozar.com/pastetheplan/?id=H1cFQxwdP
After change join order :
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
and it 's query plan : https://www.brentozar.com/pastetheplan/?id=SJv1GlPdv
Does anyone have an idea about
- Why Adaptive join caused the query to slow down?
- How does changing the join order change the execution plan?