SQL Server – Understanding Trace Flag 4199

execution-plansql server

Microsoft's KB article about Trace Flag 4199 is a bit confusing:

…any hotfix that could potentially affect the execution plan of a
query must be controlled by a trace flag. Except for fixes to bugs
that can cause incorrect results or corruption, these hotfixes are
turned off by default, and a trace flag is required to enable the fix.

NOTE: I'm assuming that a "hotfix" is a Cumulative Update (aka "CU"). If I'm wrong, please leave a comment.

So…let's suppose I'm running the latest Service Pack. SP's include all of the fixes in previous CU's. Are the hotfixes turned on for SP's (or even RTM's)? Or would Trace Flag 4199 still be required?

Best Answer

In this context, you should consider "hotfix" to mean any fix that ended up in a Service Pack, Cumulative Update, or on-demand hotfix and falls under the jurisdiction of this trace flag. These fixes are all in the most recent builds of each major supported version, but they are not used unless the trace flag is turned on. This is because, in some cases, the "fixes" can actually lead to regressions (and worse performance) - and people shouldn't expect to have major variations in plan generation just because they applied an update or service pack.

I'm not sure if this is an exhaustive list, but this article lists many of the 41xx TFs that ultimately came under the 4199 umbrella. The v4 PDF made available in this blog post may contain more flags (I haven't cross-checked) but certainly contains more info on several of the individual fixes.

At some point in the future, I suspect that all of the enhancements from TF4199 will be enabled by default in a new full major version (but not in a service pack or CU). Perhaps they will provide a trace flag to turn them all off, just like you can turn off the new cardinality estimator.