Download presentation
Presentation is loading. Please wait.
Published byOswin Melton Modified over 8 years ago
1
SQL Server Magic Buttons! What are Trace Flags and why should I care? Steinar Andersen, SQL Service Nordic AB Thanks to Thomas Kejser for peer-reviewing
2
Sponsors
3
Win a 1day SQL 2016 course Enter your email adress at http://bit.ly/sqldag for a chance to win a 1 day course in SQL Server 2016 arranged by SQL Service and LabCenterhttp://bit.ly/sqldag
4
About me SQL Server nerd since 1995 SQL Server 4.21, 6.0, 6.5, 7.0, 2000, 2005, 2008, 2012, 2014, 2016, Azure Former Member of the Board SQLUG (sqlug.se) Blog: www.sqlservice.se/blogg Twitter: @SQLSteinar Speaker at: TechDays Microsoft Sommarkollo Cloud Seminarium SQL Saturday
5
What are Trace Flags? Trace Flags are settings that in some way or another alters the behavior of various SQL Server functions. Is inherited from Sybase SQL Server code Some trace flags are still the same such as 1204, 3604, 3605, 3607, 3608 REMEMBER: Be extremely careful with trace flags, test in your test environment first. And consult professionals first if you are the slightest uncertain about the effects of your changes.
6
Why should I care? It could save you some day, like it saved me… http://www.sqlservice.se/sql-server-2012-cu1-upgrade-step- msdb110_upgrade-sql-encountered-error-547/ http://www.sqlservice.se/sql-server-2012-cu1-upgrade-step- msdb110_upgrade-sql-encountered-error-547/
7
How do I use Trace Flags? How do I turn Trace Flags on and off? *1 – You can use the DBCC TRACEON and DBCC TRACEOFF commands – You can use the -T option in the startup configuration for the SQL Server Service -You can also use the hint QUERYTRACEON in your queries: ::={ QUERYTRACEON trace_flag_number } How do I know what Trace Flags are turned on at the moment? – You can use the DBCC TRACESTATUS command Numbers from -1 to 10100 seems to be valid *2 Some Trace Flags only works in combination with others Some Trace Flags only works when used a certain way Startup, QUERYTRACEON, Global Turning on all Trace Flags – Do try this at home! (Not at work..) *3
8
Ok, ok! Now show me the Trace Flags! Statistics Locks Memory Performance Troubleshooting Other
9
Statistics 2371 Updates statistics more often on tables with more than 25000 rows 4136 *4 Uses density vector instead of histogram for cardinality estimate 2389 *4 Enable auto quick statistics update on known ascending columns 2390 *4 Enable auto quick statistics update on all columns
10
Locks 1200 *5 Prints the process ID and type of lock requested as every request for a lock is made 1204,1222 Prints deadlock info in the errorlog 1211 Disables lock escalation based on memory pressure 1224 *5 Disables lock escalation based on number of locks 1236 Fixes performance problem in scenarios with high SH-DATABASE lock activity in SQL 2012 and SQL 2014
11
Memory 834 Large Page Allocations (Might be on by default from SQL 2014) 2335 Generates Query Plans optimized for less memory To be used if you have 512 GB ram or more 2544 Produce a full memory dump in case of an exception 8032 Reverts the cache limit parameters to the SQL Server 2005 RTM setting which in general allows caches such as the Plan Cache to be larger
12
Performance 610 Minimally logged inserts to indexed tables 661 Disable the ghost record removal process 662 Prints detailed information about the work done by the ghost cleanup task when it runs next. (Use with TF 3605) 1117 Simultaneous Autogrowth in Multiple-file database 1118 Force Uniform Extent Allocation 2312 Forces the query optimizer to use the SQL Server 2014 version of the cardinality estimator 2340 Disable specific SORT optimization in Query Plan 4199 Turn on all optimizations. But from SQL 2016 on, MS has an altered strategy. New major versions will have all ”old” 4199 fixes enabled. 8780 Give the optimizer more time to find a better plan
13
Troubleshooting 902 Bypass Upgrade Scripts 3607 Skip recovery on startup 3608 Recover only Master db at startup 3609 Do not create tempdb at startup 4022 Bypass Startup procedures
14
Other 445 – ”Compile Issued” statement to errorlog (with 3605) – New! *6 2388 – Alter DBCC SHOW_STATISTICS output – New! 2529 – Displays DBCC memory allocations – New! *7 3604 - Redirect DBCC command output to query window 3605 - Directs the output of some Trace Flags to the Errorlog 3226 - Turns off ”Backup Successful” messages in errorlog
15
What Trace Flags should I always turn on? On new servers: 834 for DW servers, 1117, 1118, 3226, 4199 (not on SQL 2016) On exsisting servers: 834 for DW servers,1117, 1118, 3226
16
Read more! SQL Service Trace Flag List: http://www.sqlservice.se/updated-microsoft-sql-server- trace-flag-list/http://www.sqlservice.se/updated-microsoft-sql-server- trace-flag-list/ SQL Server Central TF List: http://www.sqlservercentral.com/articles/trace+flags/70131/ http://www.sqlservercentral.com/articles/trace+flags/70131/ MSDN TF list: http://sqlserverpedia.com/wiki/Trace_Flagshttp://sqlserverpedia.com/wiki/Trace_Flags Albert van der Sel TF list: http://antapex.org/traceflags_sqlserver.txthttp://antapex.org/traceflags_sqlserver.txt Technet Wiki TF list: http://social.technet.microsoft.com/wiki/contents/articles/13105.trace-flags-in-sql- server.aspx http://social.technet.microsoft.com/wiki/contents/articles/13105.trace-flags-in-sql- server.aspx Amit Banerjee TF list: http://troubleshootingsql.com/2012/07/01/sql-server-2008- trace-flags/http://troubleshootingsql.com/2012/07/01/sql-server-2008- trace-flags/ Paul Randal discussing TF Pro’s and Con’s: http://www.sqlskills.com/blogs/paul/the- pros-and-cons-of-trace-flags/http://www.sqlskills.com/blogs/paul/the- pros-and-cons-of-trace-flags/ Some trace flags needs to be specified with ”t” rather than with ”T” in startup options! http://technet.microsoft.com/en-us/library/ms190737(v=sql.110).aspx http://technet.microsoft.com/en-us/library/ms190737(v=sql.110).aspx
17
Read even more! QUERYTRACEON https://support.microsoft.com/en- us/kb/2801413https://support.microsoft.com/en- us/kb/2801413
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.