SQL Server Diagnostic Information Queries for May 2019

This month, I have just made some minor improvements to most of the query sets, mainly in the comments and documentation. I have also been working on the Azure SQL Database version of the queries lately.

I have 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 ten 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 2019, SQL Server 2017, SQL Server 2016 SP2, SQL Server 2016, and SQL Server 2014:


Azure SQL Database Diagnostic Information Queries

Azure SQL Database Blank Results Spreadsheet

SQL Server 2019 Diagnostic Information Queries

SQL Server 2019 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 five related Pluralsight courses, which are SQL Server 2017: Diagnosing Performance Issues with DMVs, SQL Server 2017: Diagnosing Configuration Issues with DMVs, 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 five of these courses are pretty short and to the point, at 164, 106, 67, 77, and 68 minutes respectively. Listening to these five 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!

Glenn’s Tech Insights For May 15, 2019

(Glenn’s Tech Insights… used to be part of our bi-weekly newsletter but we decided to make it a regular blog post instead so it can get more visibility. It covers interesting new hardware and software developments that are generally relevant for SQL Server).

Microarchitectural Data Sampling in Intel Processors

On May 14, 2019, news broke that a new series of speculative execution side-channel flaws are present in most existing Intel mobile, desktop, and server processors. These newly announced exploits are detailed in this advisory from Intel. Jon Masters from Red Hat has a pretty detailed explanation of these vulnerabilities here.  Here are the four CVEs:

CVE-2018-12126 Microarchitectural Store Buffer Data Sampling (MSBDS)

CVE-2018-12127 Microarchitectural Load Port Data Sampling (MLPDS)

CVE-2018-12130 Microarchitectural Fill Buffer Data Sampling (MFBDS)

CVE-2019-11091 Microarchitectural Data Sampling Uncacheable Memory (MDSUM)

For affected Intel processors, you will need OS patches plus microcode updates (BIOS updates) from your hardware vendor. You may want to consider disabling hyper-threading on affected processors. Microsoft has updated their guidance on this subject here:

SQL Server guidance to protect against Spectre, Meltdown and Micro-architectural Data Sampling vulnerabilities

Intel has a deep dive on this subject here:

Deep Dive: Intel Analysis of Microarchitectural Data Sampling

Microsoft has already released an updated PowerShell script that you can use to check your current OS and hardware status regarding these exploits. This article walks you through how to download the PowerShell script and run it to check your patching status:

How to test MDS (Zombieload) patch status on Windows systems

Figure 1 shows the results on my AMD Threadripper 2950X system (which is intrinsically less vulnerable to these types of attacks). This is after I patched Windows 10 yesterday.

image

Figure 1: Get-SpeculationControlSettings Results

BTW, the SQL Server 2017 security update for SSAS that was released on May 14, 2019 is for a completely different issue.


AMD Ryzen 3000 Series Speculation

As Computex Taipei 2019 gets closer (May 27), there are an increasing number of leaks and rumors about the exact specifications and features of the upcoming AMD Ryzen 3000 series desktop processors. This family of 7nm mainstream desktop processors will supposedly have SKUs starting with 6C/12T, going up to 16C/32T. Ryzen 3000 series processors will also have PCIe Gen 4.0 support. These processors are supposed to work in most existing 300 and 400 series AM4 socket motherboards. There will also be new 500 series motherboards that will offer additional features.


See the source image

Figure 2: 2019 AMD Client Lineup

The main unknowns at this point are the exact specifications in terms of base and max boost speeds and how much instructions per clock (IPC) improvement we will see compared to the existing AMD Ryzen 2000 series processors. Depending on what the answers to these are, we may see these processors actually having better single-threaded CPU performance compared to Intel. If that happens, it will further establish AMD as a viable competitor to Intel from nearly every perspective in this market segment. This would be great for the consumer.

Here are some videos that cover the latest rumors and leaks:

The Full Nerd ep. 93: AMD Ryzen 3000 and Radeon Navi rumors, Computex predictions, Q&A

AMD Ryzen 3000 16c specs LEAKED, RX 600 series, Nvidia SUED | Awesome Hardware #0187-A

HW News – Intel Shortage Ending, Ryzen 9 16-Core, & AMD Supercomputer

You might be thinking that this is interesting, but what does it have to do with SQL Server? If the Ryzen 3000 series performs as expected, and is successful in the marketplace, it will be a good precursor to the upcoming 7nm AMD EPYC “Rome” server processors. It will give us some hint about the IPC and clock speed increases that we can expect from the Zen 2 architecture. We should also get much more detail about the Rome processors at Computex.



Samsung Portable SSD X5 Review

If you have a fairly recent PC or Mac with a Thunderbolt 3 port, and you want/need some very high performance external storage, one of your best choices will be an external Thunderbolt 3 drive, especially one that uses an M.2 NVMe NAND flash drive with a PCIe 3.0 x4 interface. A good example is the Samsung Portable SSD X5. This drive comes in 500GB, 1TB, and 2TB capacities. These currently range in price from $217.99, to $447.99, to $897.99. This may seem expensive (and it is), but these prices have been nearly cut in half compared to when this drive was first available in August 2018.

From the exploded view in Figure 1, it appears that you might be able to disassemble the Samsung enclosure and swap in your own M.2 NVMe drive (which I am sure would void your warranty). This would let you put in any M.2 NVMe SSD that you wanted. I am not 100% sure this is possible though.


Samsung X5

Figure 1: Exploded View of Samsung Portable SSD X5


You will also need a machine with a Thunderbolt 3 port, preferably with PCIe 3.0 x4 bandwidth so that you get the full performance that the drive can deliver. Figure 2 shows the CrystalDiskMark results for this drive in my recent HP Spectre x360 13 AP0023DX laptop, which has an TB3 PCIe 3.0 x4 port.


image

Figure 2: 500GB Samsung Portable SSD X5 in TB3 PCIe 3.0 x4 port


With Windows 10 version 1809 or later, it is also very important that you set the write-caching policy to what you want it to be for that drive. The new default for external drives is Quick removal, which is safer, but disables write caching in Windows. If you want better write performance, you should enable write caching for the drive as you see in Figure 3.


image

Figure 3: Windows 10 Write-Caching Policy


Another important factor is exactly what type of Thunderbolt 3 port and PCIe 3.0 interface you have in your laptop or desktop machine. I have a two-year old Dell Precision 5520 laptop that only has a PCIe 3.0 x2 interface for its USB-C Thunderbolt 3 port. This effectively cuts your maximum sequential performance in half compared to a PCIe 3.0 x4 interface. You can see these results in Figure 4.


image

Figure 4: Performance Effect of PCIe 3.0 x4 Interface


Figure 5 shows the CrystalDiskMark results for a 1TB Samsung 970 EVO Plus M.2 NVMe drive in my HP Spectre x360 laptop. That drive is an incredible value right now, giving great performance for less than $250.00. Flash NAND SSD prices have been in steep decline over the past year. I vividly remember paying $620.00 for a 1TB Samsung 960 PRO M.2 NVMe drive in November 2017.


image

Figure 5: 1TB Samsung 970 EVO Plus M.2 NVMe SSD in HP Spectre x360



Samsung Portable SSD X5

Figure 6: Samsung Portable SSD X5


This drive is still somewhat pricey, and it does get warm under a heavy load, which happens with all M.2 drives. The built-in heatsink in the enclosure should help with that, compared to an M.2 drive inside a laptop.

Still, if you want TB3 level performance from an external drive and you have a new enough machine to support it, it is nice solution.