Post upgrade to SQL Server 2016, we saw a lot of I/O issues followed by slowness which affected the whole system.
Upon investigation, we found that top queries are delete statements.
Execution plans for delete statements:
- https://www.brentozar.com/pastetheplan/?id=BJVUG3cFN
- https://www.brentozar.com/pastetheplan/?id=B1trH3cYE
To make the system work at an acceptable rate, the legacy cardinality was turned on, which improved overall performance and brought back the situation to normal.
LEGACY_CARDINALITY_ESTIMATION=ON
Could you help me to optimize the query and reduce the cost?