Sign in with Microsoft
Sign in or create an account.
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.


The cardinality estimation logic that's known as the cardinality estimator (CE) was redesigned in SQL Server 2014 (compatibility levels 120) and SQL Server 2016 (compatibility levels 130) to improve the quality of query plans.

However, when you compile a complex query that contains many joins with a DISTINCT or GROUP BY operator, compilation may take much longer than expected.


This update that fixes this issue is included in Service Pack 1 for SQL Server 2016.

Note After you install this update, you must set trace flag 4199 to enable the fix. To set trace flag 4199, see the Trace Flags (Transact-SQL) topic at MSDN.

Each new build for SQL Server 2016 contains all the hotfixes and all the security fixes that were included with the previous build. We recommend that you install the latest build for SQL Server 2016.


To work around this issue, use one of the following methods:

  • Use trace flag 9481 to set the query optimizer cardinality estimation model to SQL Server 2012 or an earlier version.

  • Change the compatibility level of the database to SQL Server 2012 (110) or an earlier version.


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.


Learn about the terminology that Microsoft uses to describe software updates.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!