Microsoft Certified IT Professional Rudi Bruchez EI Microsoft Certified IT Professional

Rudi Bruchez EI · www.pachadata.com · rudi@pachadata.com · +33 6 22 48 76 99
Consulting, audit, performance tuning, solutions, training
SQL Server OLTP and BI / NoSQL

Version of December 2, 2026 (f6ef4055) · https://www.pachadata.com/en/docs/reference/trace-flags/

SQL Server trace flags

SQL Server trace flags by use: effect, scope, version, the equivalent USE HINT, and the flags that help you observe the optimizer.

Page co-written with Claude, who gathered the documentation and checked the output of the undocumented flags.

The trace flag

A trace flag is a number that turns on an engine behavior that is otherwise out of reach: a fix that is off by default, the legacy cardinality estimator, a diagnostic output. Microsoft documents some of them on the page DBCC TRACEON - Trace Flags; the others exist in the code without being documented.

It can be turned on at three scopes:

  • the whole instance, at startup (-T2371 in the startup parameters) or on the fly with DBCC TRACEON (2371, -1);
  • the session, with DBCC TRACEON (4136) without -1;
  • a single query, with OPTION (QUERYTRACEON 9481). The documentation guarantees this scope only for the flags it marks query, but the engine accepts others, including those in the last section.

DBCC TRACESTATUS lists the active flags. DBCC TRACEON and QUERYTRACEON require the sysadmin role; a USE HINT hint in a query requires none, which means you can put it in application code. Query Store can also apply it, since SQL Server 2022 and with the ALTER permission on the database; it does not accept QUERYTRACEON. A plan guide can also apply QUERYTRACEON to a query, whichever session sends it.

The “Scope” columns follow the documentation: G for global, S for session, Q for query. Each number links to its entry on Microsoft’s page.

Cardinality estimation and optimizer

FlagEffectScopeEquivalent or note
9481legacy estimator (model 70), whatever the compatibility levelG, S, QUSE HINT ('FORCE_LEGACY_CARDINALITY_ESTIMATION'), database option LEGACY_CARDINALITY_ESTIMATION
2312estimator of the database compatibility level, and model 120 under level 120G, S, QUSE HINT ('FORCE_DEFAULT_CARDINALITY_ESTIMATION'), equivalent from level 120 only: below that, the hint keeps model 70 (measured)
4136disables parameter sniffingG, SUSE HINT ('DISABLE_PARAMETER_SNIFFING'), database option PARAMETER_SNIFFING = OFF
4199enables the optimizer fixes released in CUs and service packs; under an old compatibility level, also those of versions newer than that level. Fixes for wrong results do not depend on itG, S, QUSE HINT ('ENABLE_QUERY_OPTIMIZER_HOTFIXES'), database option QUERY_OPTIMIZER_HOTFIXES
4138disables the row goals of TOP, FAST n, IN, EXISTSG, S, QUSE HINT ('DISABLE_OPTIMIZER_ROWGOAL')
9471minimum selectivity for the filters of a table (correlation), models 120 and laterG, S, QUSE HINT ('ASSUME_MIN_SELECTIVITY_FOR_FILTER_ESTIMATES'); no effect under model 70
4137the same for the legacy estimatorG, S, Qsame USE HINT hint; no effect under models 120 and later
9472full independence of filters (the behavior of model 70) under models 120 and laterS, Q (measured)USE HINT ('ASSUME_FULL_INDEPENDENCE_FOR_FILTER_ESTIMATES'); mentioned only on the hints page, which reserves it for Azure SQL Database, but it works on SQL Server 2022 and 2025 (measured)
9476simple containment assumption for joins instead of the base assumptionG, S, QUSE HINT ('ASSUME_JOIN_PREDICATE_DEPENDS_ON_FILTERS')
4139histogram amendment at compile time (ascending key), whatever the state of the columnG, S, QUSE HINT ('ENABLE_HIST_AMENDMENT_FOR_ASC_KEYS'); no effect under model 70 according to the documentation
2389, 2390histogram amendment for keys marked ascending (2390: or unknown)G, S, Qno effect under models 120 and later; use 4139
9488fixed guess for a multi-statement table-valued function brought down to 1 row, the value of the legacy estimatorG, S, Qirrelevant when interleaved execution applies (level 140 and later)
2453recompilation of a table variable when enough rows changeG, S, Qno effect since SQL Server 2019, replaced by deferred compilation
2301advanced optimizations for decision support queriesG, S, Q
9453disables batch modeG, S, Q
7470additional computation of the memory granted to sortsG, S, Qsince 2012 SP2 CU8 and 2014 CU10
9389additional dynamic memory for batch mode operatorsG, S

The values that these flags change in the estimates are measured in the Fixed guesses page.

Statistics

FlagEffectScopeNote
2371dynamic automatic update threshold, which drops as the table grows, instead of 500 + 20% of the rowsGno effect at compatibility level 130 and later, where this threshold is the default behavior
7471several simultaneous UPDATE STATISTICS on different statistics of the same tableGsince 2014 SP1
11024automatic update triggered by the counter of a partition, for an incremental statisticGsince 2016 SP2 and 2017 CU3

The thresholds themselves are in the Engine constants page.

Columnstore

FlagEffectScopeNote
634disables the background compression of rowgroups (tuple mover)G
10204disables merging and recompression during a REORGANIZEG, S
11631cleanup threshold for deleted rows computed on the current rows of the rowgroupGsince 2019 CU9
11634cleanup threshold for deleted rows brought down from 10% to 1%: 1% of a million rows, or 1% of the rows of the rowgroup with 11631 (Microsoft support blog post)Gsince 2019 CU9

Log, backup, and recovery

FlagEffectScopeNote
3226suppresses the messages of successful backups and restores, in the error log and the event logG
3502writes the steps of checkpoints to the error logG, S
3468disables indirect checkpoint on tempdbGsince 2016 SP1 CU5 and 2017 CU1
3459disables parallel redoGsince 2016
3261, 3262forbids differential (3261) or full (3262) backups on a secondary replica of an availability groupGSQL Server 2025
610minimally logged inserts into indexed tablesG, Sunnecessary since 2016
692disables fast insert for bulk loadsG, Ssince 2016

Locks, memory, and diagnostics

FlagEffectScopeNote
1204, 1222writes deadlocks to the error log (1222: in XML)Gthe system_health session already captures them
1211disables all lock escalationG, Sthe documentation recommends 1224 instead
1229disables lock partitioningG
174raises the plan cache buckets from 40,009 to 160,001 on 64-bitGat startup
8032goes back to the cache limits of SQL Server 2005G
2451equivalent of the last actual plan in sys.dm_exec_query_plan_statsGsince 2019; the database option LAST_QUERY_PLAN_STATS does the same
7412lightweight profiling of execution statisticsGsince 2016 SP1; no effect since 2019, where lightweight profiling is on by default
3605redirects trace messages to the error logG, Sdebugging flag
2528disables the parallelism of DBCC CHECKDBG, S
2562DBCC CHECKDB in a single batch, whatever the number of indexesG, S
1117, 1118growth of all the files of a filegroup; allocations in uniform extentsGno effect since 2016, replaced by AUTOGROW_ALL_FILES (filegroup) and MIXED_PAGE_ALLOCATION (database)
15097enables AVX-512 supportG, Ssince 2022

Undocumented flags for observing the optimizer

These flags have no entry in the documentation. They write the internal state of the optimizer and help you understand it, on a test instance. Their output reaches the Messages tab only if flag 3604 is on, for the session (DBCC TRACEON (3604)) or for the query (QUERYTRACEON 3604); without it, nothing is displayed. The excerpts below come from SQL Server 2025 CU11, with the query of the example at the bottom of the page.

FlagWhat it writesStart of the output
3604sends the output of DBCC and of the flags below to the client(no output of its own)
8605the converted tree, before simplification*** Converted Tree: ***
8606the input tree, then the trees of simplification: Simplified Tree, Join-collapsed Tree, before and after the normalization of projections*** Input Tree: ***
8607the output physical tree*** Output Tree: ***
7352the final tree of the query, operators and columnsCompute Scalar Compute Scalar (0)
8608the initial memo, with the cardinality of each group--- Initial Memo Structure ---
8615the final memo, with the cost of each alternative--- Final Memo Structure ---
8619the transformation rules appliedApply Rule: JoinCommute - A JOIN B -> B JOIN A
8621the rules applied and the tree they produce***** Rule applied: GbAggOnPrj ...
8675the end of each stage: simplification, exploration, search phases with their number of tasks and their costEnd of simplification, time: 0 net: 0 ...
2363the computation of each selectivity, models 120 and laterBegin selectivity computation
2372the memory used at each step of the compilationMemory before NNFConvert: 8

Two others change the plan instead of writing it:

FlagMeasured effectEquivalent
8649parallel plan even below the cost threshold: the plan of the join goes from serial to parallelUSE HINT ('ENABLE_PARALLEL_PLAN_PREFERENCE'), also undocumented and absent from sys.dm_exec_valid_use_hints, but accepted
8757removes the trivial plan: StatementOptmLevel goes from TRIVIAL to FULL
Example of output
USE PachaDataFormation;
DBCC TRACEON (3604);   -- output to the Messages tab, for this session

SELECT c.Nom, COUNT(*) AS nb
FROM Contact.Contact AS c
JOIN Inscription.Inscription AS i ON i.ContactId = c.ContactId
GROUP BY c.Nom
OPTION (RECOMPILE, QUERYTRACEON 8606, QUERYTRACEON 8607);

DBCC TRACEOFF (3604);

QUERYTRACEON requires the sysadmin role. RECOMPILE forces a compilation: without it, a query whose plan is in the cache does not go through the optimizer and writes nothing.

Contact

I have been an independent SQL Server consultant since 2006. I help when an application slows down, when a server costs too much in storage or licenses, or when a migration must not stop production: audit and diagnosis, query and index tuning, migrations, high availability, training. On site, or as a remote audit delivered in five working days.

rudi@pachadata.com · +33 6 22 48 76 99 · www.pachadata.com/en/contact/