Context :
Small table, stored procedure to update table, first two thousand hits no problem. After those first hits it starts to crawl to a snails pace. This stored procedure has no problems in our current environment of SQL Server 2008 R2 with the calling C# app. In our new testing environment for SQL Server 2016 we see this problem. The offending section of the query deals with a where clauses that has four comparisons of a column not equaling a param for an update of the small table:
WHERE A.Column1 <> @param1 OR A.Column2 <> @param2 etc..
My assumption was parameter sniffing but have ruled that out with various query hints.
I have also tried:
- Changing to select not update
- Playing with degrees of parallelism (MAXDOP)
- Updating stats and recompiling, even doing it mid process
- Various changes to the indexes
- Resetting connection pooling in calling C# code after X amount of iterations
- Removing any transactions controls
The only change that seems to remedy the issue is to remove the where clause and push the logic to the setter:
SET A.Column1 = CASE
WHEN A.Column1 <> @param1
THEN @param1
ELSE A.Column1
END
I don't like having to change the code, yet I have found no other resources online that could answer why SQL Server 2016 would break.
Any help would be appreciated.
option (querytraceon 9481)
? or database property-->Options --> Database scoped configurations --> Legacy Cardinality Estimation = ON. Also, can you post the actual xml execution plan (use pastebin and link it here) please ? A repro would be good to with relevant table structure.