11
12 Trace Flags In 12-ish Minutes Matt Slocum

SQL Saturday - Twelve Trace Flags In Twelve Minutes

Embed Size (px)

Citation preview

Page 1: SQL Saturday - Twelve Trace Flags In Twelve Minutes

12 Trace FlagsIn 12-ish Minutes

Matt Slocum

Page 2: SQL Saturday - Twelve Trace Flags In Twelve Minutes

Matt Slocum – Who am I?

DBA manager with a passion for SQL Server Experience with SQL Server v6.5-2014 Specialize in replication and performance tuning

MCITP: DBA SQL 2005 & 2008 MCSE: SQL 2012 Data Platform Leader of Rochester PASS SSUG Established SQL Saturday Rochester

5th annual event was in May 2016

11/17/2016 12 Trace Flags in 12-ish Minutes2 |

Page 3: SQL Saturday - Twelve Trace Flags In Twelve Minutes

How To Use Trace Flags Ad-hoc Enable

DBCC TRACEON (####, -1) #### = Trace Flag -1 (optional) = Server vs. Query level

Ad-hoc Disable DBCC TRACEOFF (####, -1)

Status DBCC TRACESTATUS

Startup Parameter - SQL Server Configuration Manager -T####

Query option OPTION (QUERYTRACEON ####)

3 | 11/17/2016 12 Trace Flags in 12-ish Minutes

Page 4: SQL Saturday - Twelve Trace Flags In Twelve Minutes

High IO Databases (TempDB & User) TF 1117 (Server level)

Grow all data files on a database when one data file needs to grow

Keeps data files consistently sized Use: On all instances that have DBs with > 1 data file

TF 1118 (Server level) Reserve an entire Extent in the data cache when one

new page is allocated Reduces overhead of allocating additional pages Use: On every instance everywhere

4 | 11/17/2016 12 Trace Flags in 12-ish Minutes

Page 5: SQL Saturday - Twelve Trace Flags In Twelve Minutes

SQL 2014/2016 Cardinality Estimator TF 9481 (Server or Session/Query level)

Use emulated SQL 2012 Cardinality Estimator Use: SQL 2014 plans are not as optimal as 2012

TF 2312 (Session/Query level) Forces SQL 2014 Native Cardinality Estimator Only need to use when 9481 is set at the server level Use: When 9481 is set on the server and you have

queries that perform better with the SQL 2014 CE

5 | 11/17/2016 12 Trace Flags in 12-ish Minutes

Page 6: SQL Saturday - Twelve Trace Flags In Twelve Minutes

Statistics Auto Updates/Estimations TF 2371 (Server level)

Reduce percentage of change required before automatically updating statistics on large tables

Use: Everywhere (SQL 2008 R2+) TF 2389/2390 (Server level)

Affects statistics on ascending columns Query optimizer will query the highest value from the

column so that it can create accurate estimates Use: When you experience bad estimates when

querying columns with ascending values

6 | 11/17/2016 12 Trace Flags in 12-ish Minutes

Page 7: SQL Saturday - Twelve Trace Flags In Twelve Minutes

Tune Query Plan Generation TF 6498 (Server level)

Enables multiple simultaneous large query compilations in SQL 2014

Use: SQL 2014 when you experience this wait: RESOURCE_SEMAPHORE_QUERY_COMPILE

TF 4136 (Server or Session/Query level) Disables parameter sniffing Causes reduced performance on skewed datasets Use: Query level preferred when parameter sniffing

causes poor performance.

7 | 11/17/2016 12 Trace Flags in 12-ish Minutes

Page 8: SQL Saturday - Twelve Trace Flags In Twelve Minutes

Optimize CPU utilization TF 8008 (Server level)

Cause the scheduler to evaluate which NUMA/soft-NUMA node to execute a query on

Prevents one CPU/NUMA node from running hot while the others are much less utilized

Use: If you see CPU contention on one NUMA node TF 8048 (Server level)

Optimizes how the scheduler assigns work to NUMA nodes with > 8 logical CPUs.

SQL 2008 - 2014 SP1 (soft-NUMA in 2014 SP2) Use: Run queries in MS article to determine if needed

8 | 11/17/2016 12 Trace Flags in 12-ish Minutes

Page 9: SQL Saturday - Twelve Trace Flags In Twelve Minutes

Suppress Successful Backup Logs TF 3226

Successful backups are not logged to the ERRORLOG

Keeps your ERRORLOG cleaner Use: All instances of SQL Server

9 | 11/17/2016 12 Trace Flags in 12-ish Minutes

Page 10: SQL Saturday - Twelve Trace Flags In Twelve Minutes

Conclusion

Test, test, TEST Official MS recommendations

https://support.microsoft.com/en-us/kb/2964518 Do your homework and see what works If you don’t need it, don’t use it SQL 2016 enables a lot automatically:

https://www.brentozar.com/archive/2016/03/sql-server-2016-death-trace-flag/

10 | 11/17/2016 12 Trace Flags in 12-ish Minutes

Page 11: SQL Saturday - Twelve Trace Flags In Twelve Minutes

Thank you!

Blog: www.sqlmatt.com Twitter: @SlocumMatt Rochester PASS Website:

http://rochesterpass.sqlpass.org/

11 | 11/17/2016 12 Trace Flags in 12-ish Minutes