This month the SQLskills team is presenting a series of blog posts aimed at helping Accidental/Junior DBAs ‘keep the SQL Server lights on’. It’s a little taster to let you know what we cover in ourÂ Immersion Event for The Accidental/Junior DBA, which we presentÂ several times each year. You can find all the other posts in this series atÂ http://www.SQLskills.com/help/AccidentalDBA. Enjoy!
In yesterdayâ€™s post I covered the basics of baselines and how to get started.Â In addition to setting up baselines, itâ€™s a good idea to get familiar with some of the free tools available to DBAs that help with continued monitoring of a SQL Server environment.
Performance Monitor and PAL
I want to start with Performance Monitor (PerfMon).Â Iâ€™ve been using PerfMon since I started working with computers and it is still one of my go-to tools.Â Beginning in SQL Server 2005, Dynamic Management Views and Functions (DMVs and DMFs) were all the rage, as they exposed so much more information than had been available to DBAs before.Â (If you donâ€™t believe me, try troubleshooting a parameter sniffing issue in SQL Server 2000.)Â But PerfMon is still a viable option because it provides information about Windows as well as SQL Server.Â There are times that itâ€™s valuable to look at that data side-by-side.Â PerfMon is on every Windows machine, itâ€™s reliable, and itâ€™s flexible.Â It provides numerous configuration options, not to mention all the different counters that you can collect.Â You have the ability to tweak it for different servers if needed, or just use the same template every time.Â It allows you to generate a comprehensive performance profile of a system for a specified time period, and you can look at performance real-time.
If youâ€™re going to use PerfMon regularly, take some time to get familiar it. When viewing live data, I like to use config files to quickly view counters of interest.Â If Iâ€™ve captured data over a period of time and I want to get a quickly view and analyze the data, I use PAL.Â PAL stands for Performance Analysis of Logs and itâ€™s written and managed by some folks at Microsoft.Â You can download PAL from CodePlex, and if you donâ€™t already have it installed, I recommend you do it now.
Ok, once PAL is installed, set up PerfMon to capture some data for you.Â If you donâ€™t know which counters to capture, donâ€™t worry.Â PAL comes with default templates that you can export and then import into PerfMon and use immediately.Â Thatâ€™s a good start, but to get a better idea of what counters are relevant for your SQL Server solution, plan to read Jonathanâ€™s post on essential PerfMon counters (it goes live this Friday, the 21st).Â Once youâ€™ve captured your data, you can then run it through PAL, which will do all the analysis for you and create pretty graphs. Â For step-by-step instructions on how to use PAL, and to view some of those lovely graphs, check out this post from Jonathan, Free Tools for the DBA: PAL Tool.Â Did you have any plans for this afternoon?Â Cancel them; youâ€™ll probably have more fun playing with data.
SQL Trace and Trace Analysis Tools
After PerfMon, my other go-to utility was SQL Trace.Â Notice I said â€śwas.â€ťÂ As much as I love SQL Trace and its GUI Profiler, theyâ€™re deprecated in SQL Server 2012.Â Iâ€™ve finally finished my mourning period and moved on to Extended Events.Â However, many of you are still running SQL Server 2008R2 and earlier so I know youâ€™re still using Trace.Â How many of you are still doing analysis by pushing the data into a table and then querying it?Â Ok, put your hands down, itâ€™s time to change that.Â Now you need to download ClearTrace and install it.
ClearTrace is a fantastic, light-weight utility that will parse and normalize trace files.Â It uses a database to store the parsed information, then queries it to show aggregated information from one trace file, or a set of files.Â The tool is very easy to use â€“ you can sort queries based on reads, CPU, duration, etc.Â And because the queries are normalized, if you group by the query text you can see the execution count for the queries.
A second utility, ReadTrace, provides the same functionality as ClearTrace, and more.Â Itâ€™s part of RML Utilities, a set of tools developed and used by Microsoft.Â ReadTrace provides the ability to dig a little deeper into the trace files, and one of the big benefits is that it allows you to compare two trace files.Â ReadTrace also stores information in a database, and normalizes the data so you can group by query text, or sort by resource usage.Â I recommend starting with ClearTrace because itâ€™s very intuitive to use, but once youâ€™re ready for more powerful analysis, start working with ReadTrace.Â Both tools include well-written documentation.
Note: If youâ€™re a newer DBA and havenâ€™t done much with Trace, thatâ€™s ok.Â Pretend youâ€™ve never heard of it, embrace Extended Events.
If youâ€™re already familiar with the tools Iâ€™ve mentioned above, and you want to up your game, then the next utility to conquer is SQLNexus.Â SQLNexus analyzes data captured by SQLDiag and PSSDiag, utilities shipped with SQL Server that Microsoft Product Support uses when troubleshooting customer issues.Â The default templates for SQLDiag and PSSDiag can be customized, by you, to capture any and all information thatâ€™s useful and relevant for your environment, and you can then run that data through SQLNexus for your analysis.Â Itâ€™s pretty slick and can be a significant time-saver, but the start-up time is higher than with the other tools Iâ€™ve mentioned.Â Itâ€™s powerful in that you can use it to quickly capture point-in-time representations of performance, either as a baseline or as a troubleshooting step.Â Either way, youâ€™re provided with a comprehensive set of information about the solution â€“ and again, you can customize it as much as you want.
Essential DMVs for Monitoring
In SQL Server 2012 SP1 there are 178 Dynamic Management Views and Functions.Â How do you know which ones are the most useful when youâ€™re looking at performance?Â Luckily, Glenn had a great set of diagnostic queries to use for monitoring and troubleshooting.Â You can find the queries on Glennâ€™s blog, and he updates them as needed, so make sure you follow his blog or check back regularly to get the latest version.Â And even though I rely on Glennâ€™s scripts, I wanted to call out a few of my own favorite DMVs:
- sys.dm_os_wait_stats â€“ I want to know what SQL Server is waiting on, when there is a problem and when there isnâ€™t.Â If youâ€™re not familiar with wait statistics, read Paulâ€™s post, Wait statistics, or please tell me where it hurts (I still chuckle at that title).
- sys.dm_exec_requests â€“ When I want to see whatâ€™s executing currently, this is where I start.
- sys.dm_os_waiting_tasks â€“ In addition to the overall waits, I want to know what tasks are waiting right now (and the wait_type).
- sys.dm_exec_query_stats â€“ I usually join to other DMVs such as sys.dm_exec_sql_text to get additional information, but thereâ€™s some great stuff in here including execution count and resource usage.
- sys.dm_exec_query_plan â€“ Very often you just want to see the plan. This DMV has cached plans as well as those for queries that are currently executing.
- sys.dm_db_stats_properties â€“ I always take a look at statistics in new systems, and when thereâ€™s a performance issue, initially just to check when they were last updated and the sample size.Â This DMF lets me do that quickly for a table, or entire database (only for SQL 2008R2 SP2 and SQL 2012 SP1).
Kimberly will dive into a few of her favorite DMVs in tomorrow’s post.
All of the utilities mentioned in this post are available for free.Â But itâ€™s worth mentioning that there are tools you can purchase that provide much of the same functionality and more.Â As an Accidental DBA, you may not always have a budget to cover the cost of these products, which is why itâ€™s important to know whatâ€™s readily available.Â And while the free tools may require more effort on your part, using them to dig into your data and figure out whatâ€™s really going on in your system is one of the best ways to learn about SQL Server and how it works.
Our online training (Pluralsight) courses that can help you with this topic:
- SQL Server: Benchmarking and Baselining
- SQL Server: Performance Troubleshooting Using Wait Statistics
- SQL Server: Collecting and Analyzing Trace Data
- SQL Server: Replacing Profiler with Extended Events