You are on page 1of 1

QL SERVER � Enabling Older Legacy Cardinality Estimation

February 9, 2019
Pinal Dave
SQL Tips and Tricks
2 Comments
Yesterday, I had a very interesting situation, one of our Comprehensive Database
Performance Health Check client immediately called me on Skype with his entire
server going continuously stopping due to a very toxic poison wait type of Resource
Semaphore. Though, we had a good idea how to fix the wait type the real issue was
the server was not staying up long enough to put us a patch in the system. It was
extremely frustrating for us and finally, we were able to deploy the patch Enabling
Older Legacy Cardinality Estimation.

SQL SERVER - Enabling Older Legacy Cardinality Estimation enablecardinality

When we see SQL Server struggling with the performance we checked the recently ran
query and realize that there was a very toxic Resource Semaphore for a query. We
got the execution plan from Query Store and we also found a fix for it. However,
every time whenever we try to put the fix, the server was going unresponsive.

Solarwinds
We all were running out of the idea to keep the server up and finally, one of the
ideas was to move the database to run older cardinality level. We immediately
Enabling Legacy Cardinality Estimation and server got stable. After a while, we
implemented our patches and were able to turn off the Legacy Cardinality
Estimation.

Here is the script to enable older legacy cardinality estimation for your database.

1
2
3
4
5
USE [YourDB]
GO
ALTER DATABASE SCOPED CONFIGURATION
SET LEGACY_CARDINALITY_ESTIMATION = ON;
GO
The following script turns off legacy cardinality estimation.

1
2
3
4
5
USE [YourDB]
GO
ALTER DATABASE SCOPED CONFIGURATION
SET LEGACY_CARDINALITY_ESTIMATION = OFF;
GO

You might also like