Applies ToSQL Server 2014 Developer - duplicate (do not use) SQL Server 2014 Enterprise - duplicate (do not use) SQL Server 2014 Enterprise Core - duplicate (do not use) SQL Server 2014 Standard - duplicate (do not use) SQL Server 2014 Service Pack 2 - duplicate (do not use) SQL Server 2016 Developer - duplicate (do not use) SQL Server 2016 Enterprise - duplicate (do not use) SQL Server 2016 Enterprise Core - duplicate (do not use) SQL Server 2016 Standard - duplicate (do not use) SQL Server 2016 Service Pack 1

Symptoms

When you query a view in Microsoft SQL Server 2014 or 2016, it might take much longer time to complete if you compare it to the execution in SQL Server 2008 R2. 

When you execute a query that uses UNION ALL and a row goal (such as TOP N clause, FAST N, or EXISTS predicate), you may notice that the query runs slower in SQL Server 2014 or later versions if you compare it to SQL Server 2008 R2.

Cause

In SQL Server 2008 R2, the Query Optimizer changes the order of different parts under UNION ALL if a row goal is present, so that the cheapest part goes first. This allows the query to finish execution earlier if the cheaper parts produce required number of rows, without continuing to execute more expensive parts. Such reordering does not occur in later versions of SQL Server.

Resolution

This issue is fixed in the following cumulative update for SQL Server:

       Cumulative Update 7 for SQL Server 2016 RTM

       Cumulative Update 4 for SQL Server 2016 SP1

       Cumulative Update 6 for SQL Server 2014 SP2

Note  The Query Optimiser must be enabled for this issue. 

For more information about query optimizer and trace flags, refer to the following links:

SQL Server Query Optimizer hotfix TF 4199 servicing model

DBCC console commands and Trace flags

Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:

Latest cumulative update for SQL Server 2016

Latest cumulative update for SQL Server 2014

Status

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

References

Learn about the terminologythat 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.