Skip to content

Commit a5d94ba

Browse files
authored
Merge pull request #2796 from BrentOzarULTD/dev
2021-02 Release
2 parents aa31bba + 7f74c8d commit a5d94ba

22 files changed

+44067
-42873
lines changed
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
11
#Set your file path
22
$FilePath = "C:\temp\SQL-Server-First-Responder-Kit"
33
$SqlVersionsPath = "$FilePath\SqlServerVersions.sql"
4+
$BlitzFirstPath = "$FilePath\sp_BlitzFirst.sql"
45

56
#All Core Blitz Without sp_BlitzQueryStore
67
Get-ChildItem -Path "$FilePath" -Filter "sp_Blitz*.sql" |
7-
Where-Object { $_.FullName -notlike "*sp_BlitzQueryStore.sql*" -and $_.FullName -notlike "*sp_BlitzInMemoryOLTP*"} |
8+
Where-Object { $_.FullName -notlike "*sp_BlitzQueryStore.sql*" -and $_.FullName -notlike "*sp_BlitzInMemoryOLTP*" -and $_.FullName -notlike "*sp_BlitzFirst*" -and $_.FullName -notlike "*sp_BlitzAnalysis*"} |
89
ForEach-Object { Get-Content $_.FullName } |
910
Set-Content -Path "$FilePath\Install-Core-Blitz-No-Query-Store.sql" -Force
1011
#append script to (re-)create SqlServerVersions Table (https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues/2429)
1112
if ( test-path "$SqlVersionsPath")
1213
{ Add-Content -Path "$FilePath\Install-Core-Blitz-No-Query-Store.sql" -Value (Get-Content -Path "$SqlVersionsPath")}
14+
if ( test-path "$BlitzFirstPath")
15+
{ Add-Content -Path "$FilePath\Install-Core-Blitz-No-Query-Store.sql" -Value (Get-Content -Path "$BlitzFirstPath")}
1316

1417

1518
#All Core Blitz With sp_BlitzQueryStore
1619
Get-ChildItem -Path "$FilePath" -Filter "sp_Blitz*.sql" |
17-
Where-Object { $_.FullName -notlike "*sp_BlitzInMemoryOLTP*"} |
20+
Where-Object { $_.FullName -notlike "*sp_BlitzInMemoryOLTP*" -and $_.FullName -notlike "*sp_BlitzFirst*" -and $_.FullName -notlike "*sp_BlitzAnalysis*"} |
1821
ForEach-Object { Get-Content $_.FullName } |
1922
Set-Content -Path "$FilePath\Install-Core-Blitz-With-Query-Store.sql" -Force
2023
#append script to (re-)create SqlServerVersions Table (https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues/2429)
2124
if ( test-path "$SqlVersionsPath")
2225
{ Add-Content -Path "$FilePath\Install-Core-Blitz-With-Query-Store.sql" -Value (Get-Content -Path "$SqlVersionsPath")}
26+
if ( test-path "$BlitzFirstPath")
27+
{ Add-Content -Path "$FilePath\Install-Core-Blitz-With-Query-Store.sql" -Value (Get-Content -Path "$BlitzFirstPath")}
2328

2429

2530
#All Scripts
2631
Get-ChildItem -Path "$FilePath" -Filter "sp_*.sql" |
27-
Where-Object { $_.FullName -notlike "*sp_BlitzInMemoryOLTP*"} |
32+
Where-Object { $_.FullName -notlike "*sp_BlitzInMemoryOLTP*" -and $_.FullName -notlike "*sp_BlitzFirst*" -and $_.FullName -notlike "*sp_BlitzAnalysis*"} |
2833
ForEach-Object { Get-Content $_.FullName } |
2934
Set-Content -Path "$FilePath\Install-All-Scripts.sql" -Force
3035
#append script to (re-)create SqlServerVersions Table (https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues/2429)
3136
if ( test-path "$SqlVersionsPath")
3237
{ Add-Content -Path "$FilePath\Install-All-Scripts.sql" -Value (Get-Content -Path "$SqlVersionsPath")}
38+
if ( test-path "$BlitzFirstPath")
39+
{ Add-Content -Path "$FilePath\Install-All-Scripts.sql" -Value (Get-Content -Path "$BlitzFirstPath")}

Documentation/sp_BlitzFirst_Checks_by_Priority.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Before adding a new check, make sure to add a Github issue for it first, and hav
66

77
If you want to change anything about a check - the priority, finding, URL, or ID - open a Github issue first. The relevant scripts have to be updated too.
88

9-
CURRENT HIGH CHECKID: 46
10-
If you want to add a new check, start at 47
9+
CURRENT HIGH CHECKID: 47
10+
If you want to add a new check, start at 48
1111

1212
| Priority | FindingsGroup | Finding | URL | CheckID |
1313
|----------|---------------------------------|---------------------------------------|-------------------------------------------------|----------|
@@ -34,6 +34,7 @@ If you want to add a new check, start at 47
3434
| 50 | Query Problems | Plan Cache Erased Recently | https://BrentOzar.com/go/freeproccache | 7 |
3535
| 50 | Query Problems | Re-Compilations/Sec High | https://BrentOzar.com/go/recompile | 16 |
3636
| 50 | Query Problems | Statistics Updated Recently | https://BrentOzar.com/go/stats | 44 |
37+
| 50 | Query Problems | High Percentage Of Runnable Queries | https://erikdarlingdata.com/go/RunnableQueue/ | 47 |
3738
| 50 | Server Performance | High CPU Utilization | https://BrentOzar.com/go/cpu | 24 |
3839
| 50 | Server Performance | High CPU Utilization - Non SQL Processes | https://BrentOzar.com/go/cpu | 28 |
3940
| 50 | Server Performance | Slow Data File Reads | https://BrentOzar.com/go/slow | 11 |

Install-All-Scripts.sql

Lines changed: 19549 additions & 19496 deletions
Large diffs are not rendered by default.

Install-Core-Blitz-No-Query-Store.sql

Lines changed: 5468 additions & 5415 deletions
Large diffs are not rendered by default.

Install-Core-Blitz-With-Query-Store.sql

Lines changed: 17827 additions & 17774 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Navigation
2222
- [sp_BlitzInMemoryOLTP: Hekaton Analysis](#sp_blitzinmemoryoltp-hekaton-analysis)
2323
- [sp_BlitzLock: Deadlock Analysis](#sp_blitzlock-deadlock-analysis)
2424
- [sp_BlitzQueryStore: Like BlitzCache, for Query Store](#sp_blitzquerystore-query-store-sale)
25-
- [sp_BlitzWho: What Queries are Running Now](#sp_blitzwho-what-queries-are-running-now)
25+
- [sp_BlitzWho: What Queries are Running Now](#sp_blitzwho-what-queries-are-running-now)
26+
- [sp_BlitzAnalysis: Query sp_BlitzFirst output tables](#sp_blitzanalysis-query-sp_BlitzFirst-output-tables)
2627
- Backups and Restores:
2728
- [sp_BlitzBackups: How Much Data Could You Lose](#sp_blitzbackups-how-much-data-could-you-lose)
2829
- [sp_AllNightLog: Back Up Faster to Lose Less Data](#sp_allnightlog-back-up-faster-to-lose-less-data)
@@ -43,7 +44,7 @@ The First Responder Kit runs on:
4344

4445
* SQL Server 2012, 2014, 2016, 2017, 2019 on Windows - fully supported.
4546
* SQL Server 2017, 2019 on Linux - yes, fully supported except sp_AllNightLog and sp_DatabaseRestore, which require xp_cmdshell, which Microsoft doesn't provide on Linux.
46-
* SQL Server 2008, 200R2 - not officially supported since it's out of Microsoft support, but we try not to make changes that would break functionality here.
47+
* SQL Server 2008, 2008R2 - not officially supported since it's out of Microsoft support, but we try not to make changes that would break functionality here.
4748
* SQL Server 2000, 2005 - not supported at all.
4849
* Amazon RDS SQL Server - fully supported.
4950
* Azure SQL DB - not supported. Some of the procedures work, but some don't, and Microsoft has a tendency to change DMVs in Azure without warning, so we don't put any effort into supporting it. If it works, great! If not, any changes to make it work would be on you. [See the contributing.md file](CONTRIBUTING.md) for how to do that.
@@ -364,6 +365,88 @@ It's designed for query tuners, so it includes things like memory grants, degree
364365
[*Back to top*](#header1)
365366

366367

368+
## sp_BlitzAnalysis: Query sp_BlitzFirst output tables
369+
370+
Retrieves data from the output tables where you are storing your sp_BlitzFirst output.
371+
372+
Parameters include:
373+
374+
* @StartDate: When you want to start seeing data from , NULL will set @StartDate to 1 hour ago.
375+
* @EndDate: When you want to see data up to, NULL will get an hour of data since @StartDate.
376+
* @Databasename: Filter results by database name where possible, Default: NULL which shows all.
377+
* @Servername: Filter results by server name, Default: @@SERVERNAME.
378+
* @OutputDatabaseName: Specify the database name where where we can find your logged sp_BlitzFirst Output table data
379+
* @OutputSchemaName: Schema which the sp_BlitzFirst Output tables belong to
380+
* @OutputTableNameBlitzFirst: Table name where you are storing sp_BlitzFirst @OutputTableNameBlitzFirst output, we default to BlitzFirst - you can Set to NULL to skip lookups against this table
381+
* @OutputTableNameFileStats: Table name where you are storing sp_BlitzFirst @OutputTableNameFileStats output, we default to BlitzFirst_FileStats - you can Set to NULL to skip lookups against this table.
382+
* @OutputTableNamePerfmonStats: Table name where you are storing sp_BlitzFirst @OutputTableNamePerfmonStats output, we default to BlitzFirst_PerfmonStats - you can Set to NULL to skip lookups against this table.
383+
* @OutputTableNameWaitStats: Table name where you are storing sp_BlitzFirst @OutputTableNameWaitStats output, we default to BlitzFirst_WaitStats - you can Set to NULL to skip lookups against this table.
384+
* @OutputTableNameBlitzCache: Table name where you are storing sp_BlitzFirst @OutputTableNameBlitzCache output, we default to BlitzCache - you can Set to NULL to skip lookups against this table.
385+
* @OutputTableNameBlitzWho: Table name where you are storing sp_BlitzFirst @OutputTableNameBlitzWho output, we default to BlitzWho - you can Set to NULL to skip lookups against this table.
386+
* @MaxBlitzFirstPriority: Max priority to include in the results from your BlitzFirst table, Default: 249.
387+
* @BlitzCacheSortorder: Controls the results returned from your BlitzCache table, you will get a TOP 5 per sort order per CheckDate, Default: 'cpu' Accepted values 'all' 'cpu' 'reads' 'writes' 'duration' 'executions' 'memory grant' 'spills'.
388+
* @WaitStatsTop: Controls the Top X waits per CheckDate from your wait stats table, Default: 10.
389+
* @ReadLatencyThreshold: Sets the threshold in ms to compare against io_stall_read_average_ms in your filestats table, Default: 100.
390+
* @WriteLatencyThreshold: Sets the threshold in ms to compare against io_stall_write_average_ms in your filestats table, Default: 100.
391+
* @BringThePain: If you are getting more than 4 hours of data from your BlitzCache table with @BlitzCacheSortorder set to 'all' you will need to set BringThePain to 1.
392+
* @Maxdop: Control the degree of parallelism that the queries within this proc can use if they want to, Default = 1.
393+
* @Debug: Show sp_BlitzAnalysis SQL commands in the messages tab as they execute.
394+
395+
Example calls:
396+
397+
Get information for the last hour from all sp_BlitzFirst output tables
398+
399+
```SQL
400+
EXEC sp_BlitzAnalysis
401+
@FromDate = NULL,
402+
@ToDate = NULL,
403+
@OutputDatabaseName = 'DBAtools',
404+
@OutputSchemaName = 'dbo',
405+
@OutputTableNameFileStats = N'BlitzFirst_FileStats',
406+
@OutputTableNamePerfmonStats = N'BlitzFirst_PerfmonStats',
407+
@OutputTableNameWaitStats = N'BlitzFirst_WaitStats',
408+
@OutputTableNameBlitzCache = N'BlitzCache',
409+
@OutputTableNameBlitzWho = N'BlitzWho';
410+
```
411+
412+
Exclude specific tables e.g lets exclude PerfmonStats by setting to NULL, no lookup will occur against the table and a skipped message will appear in the resultset
413+
414+
```SQL
415+
EXEC sp_BlitzAnalysis
416+
@FromDate = NULL,
417+
@ToDate = NULL,
418+
@OutputDatabaseName = 'DBAtools',
419+
@OutputSchemaName = 'Blitz',
420+
@OutputTableNameFileStats = N'BlitzFirst_FileStats',
421+
@OutputTableNamePerfmonStats = NULL,
422+
@OutputTableNameWaitStats = N'BlitzFirst_WaitStats',
423+
@OutputTableNameBlitzCache = N'BlitzCache',
424+
@OutputTableNameBlitzWho = N'BlitzWho';
425+
```
426+
427+
Known issues:
428+
We are likely to be hitting some big tables here and some of these queries will require scans of the clustered indexes as there are no nonclustered indexes to cover the queries by default, keep this in mind if you are planning on running this in a production environment!
429+
430+
I have noticed that the Perfmon query can ask for a big memory grant so be mindful when including this table with large volumes of data:
431+
432+
```SQL
433+
SELECT
434+
[ServerName]
435+
,[CheckDate]
436+
,[counter_name]
437+
,[object_name]
438+
,[instance_name]
439+
,[cntr_value]
440+
FROM [dbo].[BlitzFirst_PerfmonStats_Actuals]
441+
WHERE CheckDate BETWEEN @FromDate AND @ToDate
442+
ORDER BY
443+
[CheckDate] ASC,
444+
[counter_name] ASC
445+
```
446+
447+
[*Back to top*](#header1)
448+
449+
367450
## sp_BlitzBackups: How Much Data Could You Lose
368451

369452
Checks your backups and reports estimated RPO and RTO based on historical data in msdb, or a centralized location for [msdb].dbo.backupset.

SqlServerVersions.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ DELETE FROM dbo.SqlServerVersions;
4141
INSERT INTO dbo.SqlServerVersions
4242
(MajorVersionNumber, MinorVersionNumber, Branch, [Url], ReleaseDate, MainstreamSupportEndDate, ExtendedSupportEndDate, MajorVersionName, MinorVersionName)
4343
VALUES
44+
(15, 4102, 'CU9', 'https://support.microsoft.com/en-us/help/5000642', '2021-02-11', '2025-01-07', '2030-01-08', 'SQL Server 2019', 'Cumulative Update 9 '),
4445
(15, 4073, 'CU8 GDR', 'https://support.microsoft.com/en-us/help/4583459', '2021-01-12', '2025-01-07', '2030-01-08', 'SQL Server 2019', 'Cumulative Update 8 GDR '),
4546
(15, 4073, 'CU8', 'https://support.microsoft.com/en-us/help/4577194', '2020-10-01', '2025-01-07', '2030-01-08', 'SQL Server 2019', 'Cumulative Update 8 '),
4647
(15, 4063, 'CU7', 'https://support.microsoft.com/en-us/help/4570012', '2020-09-02', '2025-01-07', '2030-01-08', 'SQL Server 2019', 'Cumulative Update 7 '),
@@ -76,6 +77,7 @@ VALUES
7677
(14, 3008, 'RTM CU2', 'https://support.microsoft.com/en-us/help/4052574', '2017-11-28', '2022-10-11', '2027-10-12', 'SQL Server 2017', 'RTM Cumulative Update 2'),
7778
(14, 3006, 'RTM CU1', 'https://support.microsoft.com/en-us/help/4038634', '2017-10-24', '2022-10-11', '2027-10-12', 'SQL Server 2017', 'RTM Cumulative Update 1'),
7879
(14, 1000, 'RTM ', '', '2017-10-02', '2022-10-11', '2027-10-12', 'SQL Server 2017', 'RTM '),
80+
(13, 5882, 'SP2 CU16', 'https://support.microsoft.com/en-us/help/5000645', '2021-02-11', '2021-07-13', '2026-07-14', 'SQL Server 2016', 'Service Pack 2 Cumulative Update 16'),
7981
(13, 5865, 'SP2 CU15 GDR', 'https://support.microsoft.com/en-us/help/4583461', '2021-01-12', '2021-07-13', '2026-07-14', 'SQL Server 2016', 'Service Pack 2 Cumulative Update 15 GDR'),
8082
(13, 5850, 'SP2 CU15', 'https://support.microsoft.com/en-us/help/4577775', '2020-09-28', '2021-07-13', '2026-07-14', 'SQL Server 2016', 'Service Pack 2 Cumulative Update 15'),
8183
(13, 5830, 'SP2 CU14', 'https://support.microsoft.com/en-us/help/4564903', '2020-08-06', '2021-07-13', '2026-07-14', 'SQL Server 2016', 'Service Pack 2 Cumulative Update 14'),

Uninstall.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ IF OBJECT_ID('tempdb.dbo.#ToDelete') IS NOT NULL
1717
SELECT 'sp_AllNightLog' as ProcedureName INTO #ToDelete UNION
1818
SELECT 'sp_AllNightLog_Setup' as ProcedureName UNION
1919
SELECT 'sp_Blitz' as ProcedureName UNION
20+
SELECT 'sp_BlitzAnalysis' as ProcedureName UNION
2021
SELECT 'sp_BlitzBackups' as ProcedureName UNION
2122
SELECT 'sp_BlitzCache' as ProcedureName UNION
2223
SELECT 'sp_BlitzFirst' as ProcedureName UNION

sp_AllNightLog.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ SET NOCOUNT ON;
3030
BEGIN;
3131

3232

33-
SELECT @Version = '8.0', @VersionDate = '20210117';
33+
SELECT @Version = '8.01', @VersionDate = '20210222';
3434

3535
IF(@VersionCheckMode = 1)
3636
BEGIN
@@ -349,7 +349,7 @@ Pollster:
349349
SELECT 1
350350
FROM msdbCentral.dbo.backup_worker bw WITH (READPAST)
351351
WHERE bw.last_log_backup_finish_time < '99991231'
352-
AND bw.last_log_backup_start_time < DATEADD(MINUTE, -5, GETDATE())
352+
AND bw.last_log_backup_start_time < DATEADD(SECOND, (@rpo * -1), GETDATE())
353353
AND EXISTS (
354354
SELECT 1
355355
FROM msdb.dbo.backupset b
@@ -369,7 +369,7 @@ Pollster:
369369
bw.last_log_backup_start_time = '19000101'
370370
FROM msdbCentral.dbo.backup_worker bw
371371
WHERE bw.last_log_backup_finish_time < '99991231'
372-
AND bw.last_log_backup_start_time < DATEADD(MINUTE, -5, GETDATE())
372+
AND bw.last_log_backup_start_time < DATEADD(SECOND, (@rpo * -1), GETDATE())
373373
AND EXISTS (
374374
SELECT 1
375375
FROM msdb.dbo.backupset b
@@ -583,7 +583,7 @@ DiskPollster:
583583
SELECT 1
584584
FROM msdb.dbo.restore_worker rw WITH (READPAST)
585585
WHERE rw.last_log_restore_finish_time < '99991231'
586-
AND rw.last_log_restore_start_time < DATEADD(MINUTE, -5, GETDATE())
586+
AND rw.last_log_restore_start_time < DATEADD(SECOND, (@rto * -1), GETDATE())
587587
AND EXISTS (
588588
SELECT 1
589589
FROM msdb.dbo.restorehistory r
@@ -603,7 +603,7 @@ DiskPollster:
603603
rw.last_log_restore_start_time = '19000101'
604604
FROM msdb.dbo.restore_worker rw
605605
WHERE rw.last_log_restore_finish_time < '99991231'
606-
AND rw.last_log_restore_start_time < DATEADD(MINUTE, -5, GETDATE())
606+
AND rw.last_log_restore_start_time < DATEADD(SECOND, (@rto * -1), GETDATE())
607607
AND EXISTS (
608608
SELECT 1
609609
FROM msdb.dbo.restorehistory r

sp_AllNightLog_Setup.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ SET NOCOUNT ON;
3636

3737
BEGIN;
3838

39-
SELECT @Version = '8.0', @VersionDate = '20210117';
39+
SELECT @Version = '8.01', @VersionDate = '20210222';
4040

4141
IF(@VersionCheckMode = 1)
4242
BEGIN

0 commit comments

Comments
 (0)