SQL Server 2014 – Finding Stats Objects Used in Query

optimizationsql serversql server 2014sql-server-2012

I’ve read here that trace flags 3604, 9292 and 9204 enable debugging output that shows what statistics objects were used by the cardinality estimator during query compilation in SQL Server 2012.

They don’t work in SQL Server 2014, is there a new flag for this?

Best Answer

Yes, it’s flag 2363! Flag 3604 is just for redirecting the debugging output to the Messages window, so that stays the same in 2014.

SQL Server 2012

SELECT * FROM Test
WHERE Pred1 = 1 AND Pred2 = 2
OPTION
(
QUERYTRACEON 3604,
QUERYTRACEON 9292,
QUERYTRACEON 9204
)

SQL Server 2014

SELECT * FROM Test
WHERE Pred1 = 1 AND Pred2 = 2
OPTION
(
QUERYTRACEON 3604,
QUERYTRACEON 2363
)

Source: the SQL Server 2014 Selectivity Trace Flags section on this link.