FIX: Access violation when you compile a query and histogram amendment is enabled with default Cardinality Estimation in SQL Server 2016 and 2017

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

Symptoms


Consider the following scenario:

  • You try to run a query by using default Cardinality Estimation while histogram amendment is enabled.
  • The query includes expressions on a column that is used in one of the predicates.

In this scenario, an access violation occurs. Additionally, you receive the following error message:


Note Histogram amendment can be enabled by using the USE HINT(‘ENABLE_HIST_AMENDMENT_FOR_ASC_KEYS’) query option or trace flag 4139.

Resolution


This problem is fixed in the following updates for SQL Server:

Cumulative Update 8 for SQL Server 2017

Cumulative Update 5 for SQL Server 2016 Service Pack 2

Status


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

References


DBCC TRACEON - Trace Flags (Transact-SQL)

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