Reputation: 2149
We've upgraded a SQL Server to 2019 from 2014.
In 2014 this query was fine:
INSERT INTO [schx].[US_New]
SELECT *
FROM [schx].[US_New_Stg]
WHERE FormattedID NOT IN (SELECT FormattedID
FROM [schx].[DLT]
WHERE [Type] = 'Hierarchical Root'
);
Upon upgrade (no code changes only SQL Server Upgrade), the query killed the process to which it belonged, instead of running for 4 minutes now it went on for 8 hours, and then it would time out.
We ended up adding this: OPTION (USE HINT ( 'FORCE_LEGACY_CARDINALITY_ESTIMATION' ))
to the end of the query, and then things were fine again.
2 questions:
WHERE
clause, we left-joined both and selected NOT NULL, would that remove the need for using the Legacy CE?Thanks!
Upvotes: 0
Views: 352