SQL Server Diagnostic Information Queries for May 2018

May 3, 2018 Update: I have added a SQL Server 2016 SP2 version of the queries, since Microsoft back-ported so many new queries from SQL Server 2017 to SQL Server 2016 SP2.

This month, there are more minor updates to the SQL Server 2012 and newer versions of the queries, primarily in the comments and documentation. I have added some additional columns to many existing queries, and tried to get the newer versions uniformly updated and synchronized. There are also two new queries for the SQL Server 2012 set, to pull back new information that is exposed in SQL Server 2012 SP4.

I have also developed a T-SQL script that you can use to check whether your instance of SQL Server has been patched to mitigate against the Spectre/Meltdown CPU vulnerability. This works for SQL Server 2008 through SQL Server 2017, for on-premises and cloud-based VM (IaaS) usage. You can get the query for this here.

I often make additional minor updates to the queries periodically during the month, so if you are in doubt, downloading the latest version is always a good idea.

Rather than having a separate blog post for each version, I have just put the links for all eight major versions in this single post. There are two separate links for each version. The first one on the top left is the actual diagnostic query script, and the one below on the right is the matching blank results spreadsheet, with labeled tabs that correspond to each query in the set.

Here are links to the latest versions of these queries for Azure SQL Database, SQL Server 2017, 2016 SP2 2016, and 2014:

Azure SQL Database Diagnostic Information Queries

Azure SQL Database Blank Results Spreadsheet

SQL Server 2017 Diagnostic Information Queries

SQL Server 2017 Blank Results Spreadsheet

SQL Server 2016 SP2 Diagnostic Information Queries

SQL Server 2016 SP2 Blank Results Spreadsheet

SQL Server 2016 Diagnostic Information Queries

SQL Server 2016 Blank Results Spreadsheet

SQL Server 2014 Diagnostic Information Queries

SQL Server 2014 Blank Results Spreadsheet

Here are links to the most recent versions of these scripts for SQL Server 2012 and older:

Since SQL Server 2012 and older are out of Mainstream support from Microsoft (and because fewer of my customers are using these old versions of SQL Server), I am not going to be updating the scripts for these older versions of SQL Server every single month going forward.  I started this policy a while ago, and so far, I have not heard any complaints.

SQL Server 2012 Diagnostic Information Queries

SQL Server 2012 Blank Results Spreadsheet

SQL Server 2008 R2 Diagnostic Information Queries

SQL Server 2008 R2 Blank Results Spreadsheet

SQL Server 2008 Diagnostic Information Queries

SQL Server 2008 Blank Results Spreadsheet

SQL Server 2005 Diagnostic Information Queries

SQL Server 2005 Blank Results Spreadsheet

The basic instructions for using these queries is that you should run each query in the set, one at a time (after reading the directions for that query). It is not really a good idea to simply run the entire batch in one shot, especially the first time you run these queries on a particular server, since some of these queries can take some time to run, depending on your workload and hardware. I also think it is very helpful to run each query, look at the results (and my comments on how to interpret the results) and think about the emerging picture of what is happening on your server as you go through the complete set. I have quite a few comments and links in the script on how to interpret the results after each query.

After running each query, you need to click on the top left square of the results grid in SQL Server Management Studio (SSMS) to select all of the results, and then right-click and select “Copy with Headers” to copy all of the results, including the column headers to the Windows clipboard. Then you paste the results into the matching tab in the blank results spreadsheet.

About half of the queries are instance specific and about half are database specific, so you will want to make sure you are connected to a database that you are concerned about instead of the master system database. Running the database-specific queries while being connected to the master database is a very common mistake that I see people making when they run these queries.

Note: These queries are stored on Dropbox. I occasionally get reports that the links to the queries and blank results spreadsheets do not work, which is most likely because Dropbox is blocked wherever people are trying to connect. I am not planning on moving these to Github any time soon.

I also occasionally get reports that some of the queries simply don’t work. This usually turns out to be an issue where people have some of their user databases in 80 compatibility mode, which breaks many DMV queries, or that someone is running an incorrect version of the script for their version of SQL Server.

It is very important that you are running the correct version of the script that matches the major version of SQL Server that you are running. There is an initial query in each script that tries to confirm that you are using the correct version of the script for your version of SQL Server. If you are not using the correct version of these queries for your version of SQL Server, some of the queries are not going to work correctly.

If you want to understand how to better run and interpret these queries, you should consider listening to my three related Pluralsight courses, which are SQL Server 2014 DMV Diagnostic Queries – Part 1SQL Server 2014 DMV Diagnostic Queries – Part 2 and SQL Server 2014 DMV Diagnostic Queries – Part 3. All three of these courses are pretty short and to the point, at 67, 77, and 68 minutes respectively. Listening to these three courses is really the best way to thank me for maintaining and improving these scripts…

Please let me know what you think of these queries, and whether you have any suggestions for improvements. Thanks!


SQL Server 2017 Cumulative Update 6

On April 17, 2018, Microsoft released SQL Server 2017 CU6, which is Build 14.0.3025.34 I count 39 fixes or improvements in the public fix list.

Remember, there are not going to be any Service Packs for SQL Server 2017. We are still in the monthly release cycle for SQL Server 2017 Cumulative Updates which will last for the first year after release. After that the CU release cycle will change to quarterly until SQL Server 2017 falls out of Mainstream Support on October 11, 2022.

As always, my recommendation is to try to stay as current as possible with your SQL Server Cumulative Updates. That doesn’t mean that you should deploy them to Production the day they are released, with absolutely no testing, but it also doesn’t mean that you should not make any effort to stay current. Try to find a deployment cadence that makes sense for your organization.

PASS Summit 2018 Pre-con:Fixing Query Performance Problems from Estimates, Statistics, Heuristics, and Cardinality

PASS has publicly announced their Pre-conference Sessions for the PASS Summit 2018 in Seattle, WA. There are seven sessions on Monday, November 5, 2018, and nine sessions on Tuesday, November 6, 2018. There are good sessions on both days, from many well-known speakers.

In my honest opinion, the most valuable session for most database professionals who care about query performance is Kimberly Tripp’s Fixing Query Performance Problems from Estimates, Statistics, Heuristics, and Cardinality on Tuesday. Kimberly is the world-class master on this subject, as evidenced by her many blog posts, presentations, and Pluralsight courses.

Kimberly is a very talented and passionate presenter and teacher. Long before I worked for SQLskills (way back in 2006 when I was working at NewsGator), I had the chance to take the week-long predecessor class to the current IEPTO1: Immersion Event on Performance Tuning and Optimization – Part 1. That class was a life-changer for me, and it had a huge effect on my career.

Since then, I have seen how Kimberly presents and teaches many times over the years. I have learned so much from both her content and from her presentation and teaching style by watching her. Unlike some well-known presenters, she doesn’t use cute pictures or silly marketing gimmicks in her presentation content. She is not there to just “put on a show” for entertainment purposes.

She prepares very detailed, content-dense slides that are a very useful resource to keep and review long after the session is over. She also has the depth of knowledge and experience to actually improvise and modify her demonstrations in response to questions during a session. As any experienced presenter knows, that is a pretty big deal.

She actually understands what she is teaching at a very deep level, and she has the many years of teaching experience to explain it clearly to people with any level of experience. Despite the lack of cute pictures or costumes, she does her presentations in a very engaging manner because of her real passion for the subject.

Here are her relevant Pluralsight courses that I would recommend watching to prepare for this pre-conference session:

SQL Server: Optimizing Stored Procedure Performance

SQL Server: Optimizing Stored Procedure Performance – Part 2

SQL Server: Optimizing Ad Hoc Statement Performance

SQL Server: Indexing for Performance

SQL Server: Why Physical Database Design Matters

BTW, Kimberly did not put me up to writing this post. In fact, she might be a little embarrassed by all of this praise. She might even mock fire me on Twitter once she sees it. I just felt I needed to spread the word about this pre-conference session.

New TPC-E Result for SQL Server 2017

On March 31, 2018, Fujitsu submitted a new TPC-E result for a two-socket PRIMERGY RX2540 M4 system running SQL Server 2017 Enterprise Edition on Windows Server 2016 Standard Edition. The official TPC-E Throughput score was 6,606.75, which is a new record for a two-socket system. It was barely a new record though, since Lenovo had a previous result of 6,598.36 for a two-socket Lenovo ThinkSystem SR650 system also running SQL Server 2017 Enterprise Edition on Windows Server 2016 Standard Edition.

Both systems were using the same flagship 28-core Intel Xeon Platinum 8180 processor which will give you the most overall CPU capacity per socket, along with the highest SQL Server 2017 Enterprise Edition license costs.

Most organizations would be much better off with a lower core count, higher base clock speed processor from the same Intel Xeon Scalable Processor family, which would give them better single-threaded CPU performance and much lower SQL Server 2017 license costs. This is especially true if you can split your database workload across two servers rather than using just one server.

For example, using two, two-socket servers with the faster 12-core Intel Xeon Gold 6146 processor rather than one, two-socket server with the flagship 28-core Intel Xeon Platinum 8180 processor would give you about 10% more CPU capacity (not to mention twice the total memory and I/O capacity), about 32% better single-threaded CPU performance, and also save you about $57K in SQL Server 2017 license costs.

One unfortunate fact is that none of the server vendors besides Lenovo and Fujitsu have even bothered to submit a new TPC-E benchmark since February 2014. I would really like to see this change in the future, with new TPC-E submissions from vendors like Dell and HPE. I would also like to see submissions on AMD EPYC 7000 series machines, both for one and two-socket servers.




SQL Server Diagnostic Information Queries for April 2018

This month, there are more minor updates to the SQL Server 2014 and newer versions of the queries, primarily in the comments and documentation. I have added some additional columns to many existing queries, and tried to get the newer versions uniformly updated and synchronized.

I have also developed a T-SQL script that you can use to check whether your instance of SQL Server has been patched to mitigate against the Spectre/Meltdown CPU vulnerability. This works for SQL Server 2008 through SQL Server 2017, for on-premises and cloud-based VM (IaaS) usage. You can get the query for this here.

I often make additional minor updates to the queries periodically during the month, so if you are in doubt, downloading the latest version is always a good idea.

Rather than having a separate blog post for each version, I have just put the links for all eight major versions in this single post. There are two separate links for each version. The first one on the top left is the actual diagnostic query script, and the one below on the right is the matching blank results spreadsheet, with labeled tabs that correspond to each query in the set.

Here are links to the latest versions of these queries for Azure SQL Database, SQL Server 2017, 2016, and 2014:

Azure SQL Database Diagnostic Information Queries

Azure SQL Database Blank Results Spreadsheet

SQL Server 2017 Diagnostic Information Queries

SQL Server 2017 Blank Results Spreadsheet

SQL Server 2016 Diagnostic Information Queries

SQL Server 2016 Blank Results Spreadsheet

SQL Server 2014 Diagnostic Information Queries

SQL Server 2014 Blank Results Spreadsheet

Here are links to the most recent versions of these scripts for SQL Server 2012 and older:

Since SQL Server 2012 and older are out of Mainstream support from Microsoft (and because fewer of my customers are using these old versions of SQL Server), I am not going to be updating the scripts for these older versions of SQL Server every single month going forward.  I started this policy a while ago, and so far, I have not heard any complaints.

SQL Server 2012 Diagnostic Information Queries

SQL Server 2012 Blank Results Spreadsheet

SQL Server 2008 R2 Diagnostic Information Queries

SQL Server 2008 R2 Blank Results Spreadsheet

SQL Server 2008 Diagnostic Information Queries

SQL Server 2008 Blank Results Spreadsheet

SQL Server 2005 Diagnostic Information Queries

SQL Server 2005 Blank Results Spreadsheet

The basic instructions for using these queries is that you should run each query in the set, one at a time (after reading the directions for that query). It is not really a good idea to simply run the entire batch in one shot, especially the first time you run these queries on a particular server, since some of these queries can take some time to run, depending on your workload and hardware. I also think it is very helpful to run each query, look at the results (and my comments on how to interpret the results) and think about the emerging picture of what is happening on your server as you go through the complete set. I have quite a few comments and links in the script on how to interpret the results after each query.

After running each query, you need to click on the top left square of the results grid in SQL Server Management Studio (SSMS) to select all of the results, and then right-click and select “Copy with Headers” to copy all of the results, including the column headers to the Windows clipboard. Then you paste the results into the matching tab in the blank results spreadsheet.

About half of the queries are instance specific and about half are database specific, so you will want to make sure you are connected to a database that you are concerned about instead of the master system database. Running the database-specific queries while being connected to the master database is a very common mistake that I see people making when they run these queries.

Note: These queries are stored on Dropbox. I occasionally get reports that the links to the queries and blank results spreadsheets do not work, which is most likely because Dropbox is blocked wherever people are trying to connect. I am not planning on moving these to Github any time soon.

I also occasionally get reports that some of the queries simply don’t work. This usually turns out to be an issue where people have some of their user databases in 80 compatibility mode, which breaks many DMV queries, or that someone is running an incorrect version of the script for their version of SQL Server.

It is very important that you are running the correct version of the script that matches the major version of SQL Server that you are running. There is an initial query in each script that tries to confirm that you are using the correct version of the script for your version of SQL Server. If you are not using the correct version of these queries for your version of SQL Server, some of the queries are not going to work correctly.

If you want to understand how to better run and interpret these queries, you should consider listening to my three related Pluralsight courses, which are SQL Server 2014 DMV Diagnostic Queries – Part 1SQL Server 2014 DMV Diagnostic Queries – Part 2 and SQL Server 2014 DMV Diagnostic Queries – Part 3. All three of these courses are pretty short and to the point, at 67, 77, and 68 minutes respectively. Listening to these three courses is really the best way to thank me for maintaining and improving these scripts…

Please let me know what you think of these queries, and whether you have any suggestions for improvements. Thanks!

SQL Server 2017 Cumulative Update 5

On March 20, 2018, Microsoft released SQL Server 2017 Cumulative Update 5, which is Build 14.0.3023.8. I count 14 hotfixes in the public fix list. It is good to see Microsoft getting back on schedule for their first year CU releases for SQL Server 2017, which are supposed to happen every month.

There are quite a few fixes for performance and the database engine area in this CU. Remember, there are not going to be any Service Packs for SQL Server 2017, so you are going to want to test and deploy SQL Server 2017 Cumulative Updates as they become available.

As always, I think it is a good idea to make an effort to stay current on Cumulative Updates, as does Microsoft.

Recent SQL Server Software Updates

The third week of March 2018 has seen a plethora of SQL Server related software updates from Microsoft. These include:

SQL Server 2017 CU5

SQL Server 2016 SP1 CU8

SQL Server 2014 SP2 CU11

This list covers all of the currently supported branches of these major versions of SQL Server, meaning that if you are on a different branch of one of these versions (such as SQL Server 2014 SP1 for example), you are not on a supported branch and there won’t be anymore Cumulative Updates for that branch

We also saw a new minor release of SQL Server Management Studio (SSMS). The main purpose of this release was to add support for SQL Database Managed Instance, along with some bug fixes in other areas.

SSMS 17.6



SQL Server Diagnostic Information Queries for March 2018

This month, there are more minor updates to the all of the versions of the queries, primarily in the comments and documentation. I have made the most changes to the SQL Server 2017 version this month.

I have also developed a T-SQL script that you can use to check whether your instance of SQL Server has been patched to mitigate against the Spectre/Meltdown CPU vulnerability. This works for SQL Server 2008 through SQL Server 2017, for on-premises and cloud-based VM (IaaS) usage. You can get the query for this here.

I often make additional minor updates to the queries periodically during the month, so if you are in doubt, downloading the latest version is always a good idea.

Rather than having a separate blog post for each version, I have just put the links for all eight major versions in this single post. There are two separate links for each version. The first one on the top left is the actual diagnostic query script, and the one below on the right is the matching blank results spreadsheet, with labeled tabs that correspond to each query in the set.

Here are links to the latest versions of these queries for Azure SQL Database, SQL Server 2017, 2016, and 2014:

Azure SQL Database Diagnostic Information Queries

Azure SQL Database Blank Results Spreadsheet

SQL Server 2017 Diagnostic Information Queries

SQL Server 2017 Blank Results Spreadsheet

SQL Server 2016 Diagnostic Information Queries

SQL Server 2016 Blank Results Spreadsheet

SQL Server 2014 Diagnostic Information Queries

SQL Server 2014 Blank Results Spreadsheet

Here are links to the most recent versions of these scripts for SQL Server 2012 and older:

Since SQL Server 2012 and older are out of Mainstream support from Microsoft (and because fewer of my customers are using these old versions of SQL Server), I am not going to be updating the scripts for these older versions of SQL Server every single month going forward.  I started this policy a while ago, and so far, I have not heard any complaints.

SQL Server 2012 Diagnostic Information Queries

SQL Server 2012 Blank Results Spreadsheet

SQL Server 2008 R2 Diagnostic Information Queries

SQL Server 2008 R2 Blank Results Spreadsheet

SQL Server 2008 Diagnostic Information Queries

SQL Server 2008 Blank Results Spreadsheet

SQL Server 2005 Diagnostic Information Queries

SQL Server 2005 Blank Results Spreadsheet

The basic instructions for using these queries is that you should run each query in the set, one at a time (after reading the directions for that query). It is not really a good idea to simply run the entire batch in one shot, especially the first time you run these queries on a particular server, since some of these queries can take some time to run, depending on your workload and hardware. I also think it is very helpful to run each query, look at the results (and my comments on how to interpret the results) and think about the emerging picture of what is happening on your server as you go through the complete set. I have quite a few comments and links in the script on how to interpret the results after each query.

After running each query, you need to click on the top left square of the results grid in SQL Server Management Studio (SSMS) to select all of the results, and then right-click and select “Copy with Headers” to copy all of the results, including the column headers to the Windows clipboard. Then you paste the results into the matching tab in the blank results spreadsheet.

About half of the queries are instance specific and about half are database specific, so you will want to make sure you are connected to a database that you are concerned about instead of the master system database. Running the database-specific queries while being connected to the master database is a very common mistake that I see people making when they run these queries.

Note: These queries are stored on Dropbox. I occasionally get reports that the links to the queries and blank results spreadsheets do not work, which is most likely because Dropbox is blocked wherever people are trying to connect. I am not planning on moving these to Github any time soon.

I also occasionally get reports that some of the queries simply don’t work. This usually turns out to be an issue where people have some of their user databases in 80 compatibility mode, which breaks many DMV queries, or that someone is running an incorrect version of the script for their version of SQL Server.

It is very important that you are running the correct version of the script that matches the major version of SQL Server that you are running. There is an initial query in each script that tries to confirm that you are using the correct version of the script for your version of SQL Server. If you are not using the correct version of these queries for your version of SQL Server, some of the queries are not going to work correctly.

If you want to understand how to better run and interpret these queries, you should consider listening to my three related Pluralsight courses, which are SQL Server 2014 DMV Diagnostic Queries – Part 1SQL Server 2014 DMV Diagnostic Queries – Part 2 and SQL Server 2014 DMV Diagnostic Queries – Part 3. All three of these courses are pretty short and to the point, at 67, 77, and 68 minutes respectively. Listening to these three courses is really the best way to thank me for maintaining and improving these scripts…

Please let me know what you think of these queries, and whether you have any suggestions for improvements. Thanks!

New CPU Microcode Updates for Intel Processors

Intel has released a new round of CPU microcode updates that address the Spectre variant #2 CPU vulnerability that now include older processor microarchitectures (all the way back to Haswell). There is always a delay between when Intel makes these updates available and when the system vendors and motherboard manufacturers do their validation and release BIOS updates.

A number of system vendors and motherboard manufacturers have special sites where you can more easily locate the latest BIOS update for your system. You should make a point of periodically checking to see if any BIOS updates are available for your systems. Here is a list of some of the more popular vendors:


ASRock

ASUS

Dell

Dell (Server)

Gigabyte

HP

HPE

Lenovo

MSI


I have written quite a bit about Spectre and Meltdown, including my latest article for SQLPerformance.com here.



SQL Server 2017 Cumulative Update 4

On February 20, 2018, Microsoft released SQL Server 2017 Cumulative Update 4, which is Build 14.0.3022.28. I count 55 hotfixes in the public fix list. There is a special T-SQL script in the release notes that you need to run if you are using Query Store and previously ever had SQL Server 2017 CU2 installed (and you were using Query Store on any of your databases at that time). The script will look for any plans that were forced while you were running SQL Server 2017 CU2, and if it finds any, it will unforce them, and then clear them from Query Store.

There are also quite a few updates for Columnstore indexes and for Availability Groups. Remember, there are not going to be any Service Packs for SQL Server 2017, so you are going to want to test and deploy SQL Server 2017 Cumulative Updates as they become available.

As always, I think it is a good idea to make an effort to stay current on Cumulative Updates, as does Microsoft.