Skip to content

Commit

Permalink
Merge pull request #160 from VladDBA/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
VladDBA authored Dec 27, 2023
2 parents 6d7f150 + dfac731 commit adb97f9
Show file tree
Hide file tree
Showing 16 changed files with 2,367 additions and 827 deletions.
1,777 changes: 1,367 additions & 410 deletions PSBlitz.ps1

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Outputs the following to an Excel spreadsheet or to an HTML report:
- Index-related issues and recommendations - from sp_BlitzIndex
- Top 10 most resource intensive queries - from sp_BlitzCache
- Deadlock related information from the past 15 days - from sp_BlitzLock
- Information about Azure SQL DB resources, resource usage, database and database configuration
- Information about all databases and their files or for a single database in case of a database-specific check
- Query Store information in the case of a database-specific check on an eligible database - from sp_BlitzQueryStore
- Statistics details for a given database - in the case of database-specific check or if a database accounts for at least 2/3 of the sp_BlitzCache data
Expand Down Expand Up @@ -87,6 +88,7 @@ opened transactions, statistics and index fragmentation info:
- GetDbInfo.sql
- GetBlitzWhoData.sql
- GetInstanceInfo.sql
- GetAzureSQLDBInfo.sql
- GetTempDBUsageInfo.sql
- GetOpenTransactions.sql
- GetIndexInfoForWholeDB.sql
Expand Down Expand Up @@ -235,6 +237,10 @@ Otherwise you can navigate in PowerShell to the directory where the script is an
```PowerShell
.\PSBlitz.ps1 Server01\SQL01 -ToHTML Y -ZipOutput Y
```
12. Run it against the YourDatabase database hosted in Azure SQL DB at myserver.database.windows.net port 1433 via SQL login and password
```PowerSHell
.\PSBlitz.ps1 yourserver.database.windows.net,1433:YourDatabase -SQLLogin DBA1 -SQLPass SuperSecurePassword
```
Note that `-ServerName` is a positional parameter, so you don't necessarily have to specify the parameter's name as long as the first thing after the script's name is the instance
[*Back to top*](#header1)
Expand Down
326 changes: 326 additions & 0 deletions Resources/GetAzureSQLDBInfo.sql

Large diffs are not rendered by default.

31 changes: 7 additions & 24 deletions Resources/GetBlitzWhoData.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/*
Part of PSBlitz - https://github.com/VladDBA/PSBlitz
License - https://github.com/VladDBA/PSBlitz/blob/main/LICENSE
*/

SET NOCOUNT ON;
SET STATISTICS XML OFF;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;

/*Create supporting index*/
CREATE NONCLUSTERED INDEX [IX_AGG]
Expand All @@ -14,21 +18,12 @@ SET @DatabaseName = N'';

/*Standard output*/
SELECT [CheckDate],
[start_time],
[elapsed_time],
[session_id],
[database_name],
[query_text],
[query_cost],
CASE
WHEN [query_plan] IS NOT NULL THEN 'RunningNow_'
+ CAST([session_id] AS VARCHAR(5))
+ '_'
+ REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(19), [start_time], 120), ':', ''), ' ', '_'), '-', '')
+ '_'
+ ISNULL(CONVERT(VARCHAR(20), [query_plan_hash], 1), '0x00')
+ '.sqlplan'
ELSE '-- N/A --'
END AS [sqlplan_file],
[status],
[cached_parameter_info],
[wait_info],
Expand All @@ -44,7 +39,6 @@ SELECT [CheckDate],
[fix_parameter_sniffing],
[client_interface_name],
[login_time],
[start_time],
[request_time],
[request_cpu_time],
[request_logical_reads],
Expand Down Expand Up @@ -86,7 +80,7 @@ SELECT [CheckDate],
[forced_grant_count],
[workload_group_name],
[resource_pool_name],
[context_info]
[query_hash]
FROM [tempdb].[dbo].[BlitzWho_..BlitzWhoOut..]
WHERE [database_name] = CASE
WHEN @DatabaseName = N'' THEN [database_name]
Expand Down Expand Up @@ -118,16 +112,6 @@ SELECT [agg].[start_time],
[who].[outer_command],
[who].[query_plan],
[who].[query_cost],
CASE
WHEN [query_plan] IS NOT NULL THEN 'RunningNow_'
+ CAST([agg].[session_id] AS VARCHAR(5))
+ '_'
+ REPLACE(REPLACE(REPLACE(CONVERT(VARCHAR(19), [agg].[start_time], 120), ':', ''), ' ', '_'), '-', '')
+ '_'
+ ISNULL(CONVERT(VARCHAR(20), [who].[query_plan_hash], 1), '0x00')
+ '.sqlplan'
ELSE '-- N/A --'
END AS [sqlplan_file],
[who].[status],
[who].[cached_parameter_info],
[who].[wait_info],
Expand Down Expand Up @@ -184,7 +168,6 @@ SELECT [agg].[start_time],
[who].[forced_grant_count],
[who].[workload_group_name],
[who].[resource_pool_name],
[who].[context_info],
[agg].[query_hash],
[who].[query_plan_hash]
FROM [tempdb].[dbo].[BlitzWho_..BlitzWhoOut..] [who]
Expand Down
Loading

0 comments on commit adb97f9

Please sign in to comment.