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.

Slides:



Advertisements
Similar presentations
Database Updates Made Easy In WebFocus Using SQL And HTML Painter Sept 2011 Lender Processing Services 1.
Advertisements

SQL Server 2005 SP2 Israeli SQL Server User Group March 2005 Ami Levin
How a little code can help with support.. Chris Barba – Developer at Cimarex Energy Blog:
Module 5: Upgrading to SQL Server 7.0. Overview Planning an Upgrade Preparing to Upgrade Verifying the Upgrade Setting a Compatibility Level.
Troubleshooting SQL Server Performance: Tips &Tools Amit Khandelwal.
SQL SERVER AUDITING. Jean Joseph DBA/Consultant Contact Info: Blog:
SQL SERVER CONFIGURATION OPTIONS AND TRACE FLAG SECRETS Kevin Kline SQL Sentry, Director of Engineering on Twitter, FB, LI Blogs at
How to kill SQL Server Performance Håkan Winther.
Does the Optimistic Concurrency resolve your blocking problems Margarita Naumova, SQL Master Academy.
SQL Server Statistics DEMO SQL Server Statistics SREENI JULAKANTI,MCTS.MCITP SQL SERVER Database Administration.
You Inherited a Database Now What? What you should immediately check and start monitoring for. Tim Radney, Senior DBA for a top 40 US Bank President of.
Let’s Get It Started Lori Edwards, SQL Sentry. Introduction  Sales Engineer for SQL Sentry since 2/2013  Previously – DBA since 2003  PASS volunteer.
SQL Server Performance Tuning Starter Kit Randolph West | Born SQL.
ProgressBook Suite Maintenance
Basic Outputs to Troubleshooting Queries.
SQL Database Management
Start-SPPowerShell – Introduction to PowerShell for SharePoint Admins and Developers Paul BAker.
Common SQL keywords. Building and using CASE Tools Data Base with Microsoft SQL-Server and C#
SQL Server Statistics and its relationship with Query Optimizer
ASE Optdiag Features including dynamic_histogram
Parameter Sniffing in SQL Server Stored Procedures
SQL 2016 R Services a.k.a. leveraging your local data lake
You Inherited a Database Now What?
What Is a Latch? …and Why Do I Care? Eddie Wuerch, mcm
SQL Server Statistics 101 Travis Whitley Senior Consultant, Oakwood Systems whitleysql.wordpress.com.
SQL Server Performance Tuning
Stored Procedures – Facts and Myths
SharePoint Solutions Architect, Protiviti
Antonio Abalos Castillo
Hitting the SQL Server “Go Faster” Button
Query Tuning without Production Data
Finding more space for your tight environment
Query Tuning without Production Data
Query Tuning without Production Data
Introduction to SQL Server Management for the Non-DBA
Hustle and Bustle of SQL Pages
The Top 5 SQL Server Mistakes
Introduction to Execution Plans
Query Execution Expectation-Reality Denis Reznik
Working with Very Large Tables Like a Pro in SQL Server 2014
Universal SQL Installations Framework (Script review and Demo)
Dynamics AX Performance
Hitting the SQL Server “Go Faster” Button
Now where does THAT estimate come from?
Cardinality Estimator 2014/2016
Query Optimization Statistics: The Driving Force Behind Good Performance G. Vern Rabe -
Statistics What are the chances
TechEd /24/2018 8:21 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered.
Statistics: What are they and How do I use them
SQL Server performance tuning on Azure IaaS
Turbo-Charged Transaction Logs
TEMPDB – INTERNALS AND USAGE
Hugo Kornelis Now where does THAT estimate come from? The nuts and bolts of cardinality estimation.
SQL Server performance tuning on Azure IaaS
When I Use NOLOCK AND OTHER HINTS
Ascending Key Problem in SQL Server Large Tables
Targeting Wait Statistics with Extended Events
Parameter Sniffing: the Good, the Bad, and the Ugly
You Inherited a Database Now What?
Introduction to Execution Plans
Parameter Sniffing: the Good,the Bad, and the Ugly
Parameter Sniffing: the Good, the Bad, and the Ugly
10 Administration etc..
Diving into Query Execution Plans
Introduction to Execution Plans
DIY GP Maintenance Paul Johnson.
Isolation Levels Understanding Transaction Temper Tantrums
Michelle Haarhues Keeping up with SSMS.
Introduction to Execution Plans
Working with Very Large Tables Like a Pro in SQL Server 2017
Presentation transcript:

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

Sponsors

Win a 1day SQL 2016 course  Enter your adress at for a chance to win a 1 day course in SQL Server 2016 arranged by SQL Service and LabCenterhttp://bit.ly/sqldag

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:   Speaker at:  TechDays  Microsoft Sommarkollo  Cloud Seminarium  SQL Saturday

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.

Why should I care?  It could save you some day, like it saved me…  msdb110_upgrade-sql-encountered-error-547/ msdb110_upgrade-sql-encountered-error-547/

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 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

Ok, ok! Now show me the Trace Flags!  Statistics  Locks  Memory  Performance  Troubleshooting  Other

Statistics  2371  Updates statistics more often on tables with more than 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

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

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

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

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

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  Redirect DBCC command output to query window  Directs the output of some Trace Flags to the Errorlog  Turns off ”Backup Successful” messages in errorlog

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

Read more!  SQL Service Trace Flag List: trace-flag-list/ trace-flag-list/  SQL Server Central TF List:  MSDN TF list:  Albert van der Sel TF list:  Technet Wiki TF list: server.aspx server.aspx  Amit Banerjee TF list: trace-flags/ trace-flags/  Paul Randal discussing TF Pro’s and Con’s: pros-and-cons-of-trace-flags/ pros-and-cons-of-trace-flags/  Some trace flags needs to be specified with ”t” rather than with ”T” in startup options!

Read even more!  QUERYTRACEON us/kb/ https://support.microsoft.com/en- us/kb/