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

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.

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!

×