FIX: Number of rows is underestimated for a query predicate that involves a scalar user-defined function in SQL Server 2014

Consider the following scenario:

  • You have a query that contains a predicate that involves a parameterized scalar user-defined function.
  • There are multiple combinations of input parameter values that may produce the same result by this user-defined function.
  • SQL Server uses the New Cardinality Estimator in which the database compatibility mode is set to 120.

In this scenario, when you run the query, you experience poor query performance because of an incorrectly estimated number of rows for the predicate that involves the user-defined function in the query plan.
This problem was first fixed in the following cumulative update for SQL Server:

After you install this cumulative update package, you have to enable trace flag 4199. To do this, you can add the -T4199 startup parameter. Or, you can use the dbcc traceon(4199) statement for a specific session.

About cumulative updates for SQL Server
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:

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Learn about the terminology Microsoft uses to describe software updates.
Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Article ID: 3151176 - Last Review: 05/31/2016 06:37:00 - Revision: 2.0

Microsoft SQL Server 2014 Developer, Microsoft SQL Server 2014 Enterprise, Microsoft SQL Server 2014 Standard

  • kbqfe kbfix kbexpertiseinter kbsurveynew KB3151176