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: