FIX: Inefficient query plan is used for a query requiring order by partitioning column of a table with single partition

Applies to: SQL Server 2016 DeveloperSQL Server 2016 EnterpriseSQL Server 2016 Enterprise Core

Symptoms


You execute a query on a partitioned table that contains only one partition in SQL Server 2016. If the query requests a sort operation on the key columns of an index, SQL Server query optimizer doesn't match the correct index. In this case, the query optimizer uses an inefficient query plan and adds a SORT operator.

Resolution


The fix for this issue is included in the following cumulative update for SQL Server:


Notes
  • This change will be enabled only if trace flag 4199 is enabled, if the database scope of database configuration QUERY_OPTIMIZER_HOTFIXES is set to ON, or if query hint ENABLE_QUERY_OPTIMIZER_HOTFIXES is used.
  • The ENABLE_QUERY_OPTIMIZER_HOTFIXES query hint is available starting in SQL Server 2016 SP1.

About cumulative updates for SQL Server

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 terminology Microsoft uses to describe software updates.