Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
*.vsidx
*.lock
.DS_Store
/.vs
2,569 changes: 1,695 additions & 874 deletions Install-All/DarlingData.sql

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions sp_HumanEvents/sp_HumanEventsBlockViewer.sql
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ BEGIN
JOIN sys.dm_xe_session_targets AS t
ON s.address = t.event_session_address
WHERE s.name = @session_name
ORDER BY
ORDER BY
t.target_name
OPTION(RECOMPILE);
END;
Expand All @@ -956,7 +956,7 @@ BEGIN
JOIN sys.dm_xe_database_session_targets AS t
ON s.address = t.event_session_address
WHERE s.name = @session_name
ORDER BY
ORDER BY
t.target_name
OPTION(RECOMPILE);
END;
Expand Down Expand Up @@ -1155,7 +1155,7 @@ BEGIN
CROSS APPLY x.x.nodes('/RingBufferTarget/event') AS e(x)
WHERE e.x.exist('@name[ .= "blocked_process_report"]') = 1
AND e.x.exist('@timestamp[. >= sql:variable("@start_date") and .< sql:variable("@end_date")]') = 1
ORDER BY
ORDER BY
event_timestamp DESC
) AS most_recent
OPTION(RECOMPILE);
Expand Down Expand Up @@ -1187,7 +1187,7 @@ BEGIN
CROSS APPLY x.x.nodes('/event') AS e(x)
WHERE e.x.exist('@name[ .= "blocked_process_report"]') = 1
AND e.x.exist('@timestamp[. >= sql:variable("@start_date") and .< sql:variable("@end_date")]') = 1
ORDER BY
ORDER BY
event_timestamp DESC
) AS most_recent
OPTION(RECOMPILE);
Expand Down Expand Up @@ -1258,7 +1258,7 @@ BEGIN
event_timestamp = w.x.value('(//@timestamp)[1]', 'datetime2')
FROM #sp_server_diagnostics_component_result AS wi
CROSS APPLY wi.sp_server_diagnostics_component_result.nodes('//event') AS w(x)
ORDER BY
ORDER BY
event_timestamp DESC
) AS most_recent
OPTION(RECOMPILE);
Expand Down Expand Up @@ -2121,7 +2121,7 @@ WITH
varchar(400),
blocking_desc +
' </* ' +
blocked_desc
blocked_desc
)
FROM #blocking AS b
WHERE NOT EXISTS
Expand Down Expand Up @@ -2867,26 +2867,26 @@ BEGIN
SELECT
check_id = -1,
database_name = N'erikdarling.com',
object_name =
N'sp_HumanEventsBlockViewer version ' +
CONVERT(nvarchar(30), @version) +
object_name =
N'sp_HumanEventsBlockViewer version ' +
CONVERT(nvarchar(30), @version) +
N'.',
finding_group = N'https://code.erikdarling.com',
finding =
N'blocking events from ' +
CONVERT(nvarchar(30), @actual_start_date, 126) +
N' to ' +
CONVERT(nvarchar(30), @actual_end_date, 126) +
N' (' + CONVERT(nvarchar(30), @actual_event_count) +
N' total events' +
CASE
WHEN @max_blocking_events > 0
AND @actual_event_count >= @max_blocking_events
THEN N', limited to most recent ' +
CONVERT(nvarchar(30), @max_blocking_events) +
N')'
ELSE N')'
END +
finding =
N'blocking events from ' +
CONVERT(nvarchar(30), @actual_start_date, 126) +
N' to ' +
CONVERT(nvarchar(30), @actual_end_date, 126) +
N' (' + CONVERT(nvarchar(30), @actual_event_count) +
N' total events' +
CASE
WHEN @max_blocking_events > 0
AND @actual_event_count >= @max_blocking_events
THEN N', limited to most recent ' +
CONVERT(nvarchar(30), @max_blocking_events) +
N')'
ELSE N')'
END +
N'.',
1;

Expand Down Expand Up @@ -3716,8 +3716,8 @@ BEGIN
SELECT
check_id = 2147483647,
database_name = N'erikdarling.com',
object_name =
N'sp_HumanEventsBlockViewer version ' +
object_name =
N'sp_HumanEventsBlockViewer version ' +
CONVERT(nvarchar(30), @version) + N'.',
finding_group = N'https://code.erikdarling.com',
finding = N'thanks for using me!',
Expand Down
43 changes: 22 additions & 21 deletions sp_IndexCleanup/sp_IndexCleanup.sql
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
table_name sysname NOT NULL,
index_id integer NOT NULL,
index_name sysname NOT NULL,
can_compress bit NOT NULL
INDEX filtered_objects CLUSTERED
(database_id, schema_id, object_id, index_id)
can_compress bit NOT NULL
);

create CLUSTERED INDEX filtered_objects ON #filtered_objects (database_id, schema_id, object_id, index_id)

CREATE TABLE
#operational_stats
(
Expand Down Expand Up @@ -483,7 +483,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
page_io_latch_wait_in_ms bigint NULL,
page_compression_attempt_count bigint NULL,
page_compression_success_count bigint NULL,
PRIMARY KEY CLUSTERED
PRIMARY KEY CLUSTERED
(database_id, schema_id, object_id, index_id)
);

Expand Down Expand Up @@ -583,11 +583,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* When this is a target, the index which points to it as a supersedes in consolidation */
superseded_by nvarchar(4000) NULL,
/* Priority score from 0-1 to determine which index to keep (higher is better) */
index_priority decimal(10,6) NULL
INDEX index_analysis CLUSTERED
(database_id, schema_id, object_id, index_id)
index_priority decimal(10,6) NULL
);

CREATE CLUSTERED INDEX index_analysis on #index_analysis
(database_id, schema_id, object_id, index_id)

CREATE TABLE
#compression_eligibility
(
Expand Down Expand Up @@ -782,10 +783,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
index_name sysname NULL,
filter_definition nvarchar(max) NULL,
missing_included_columns nvarchar(max) NULL,
should_include_filter_columns bit NOT NULL,
INDEX c CLUSTERED
(database_id, schema_id, object_id, index_id)
should_include_filter_columns bit NOT NULL,
);
create CLUSTERED INDEX c ON #filtered_index_columns_analysis
(database_id, schema_id, object_id, index_id)

/* Parse @include_databases comma-separated list */
IF @get_all_databases = 1
Expand Down Expand Up @@ -1192,12 +1193,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ELSE 0
END
FROM ' + QUOTENAME(@current_database_name) + N'.sys.indexes AS i
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.tables AS t
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.tables AS t
ON i.object_id = t.object_id
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
ON i.object_id = v.object_id
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.schemas AS s
ON ISNULL(t.schema_id, v.schema_id) = s.schema_id
ON ISNULL(t.schema_id, v.schema_id) = s.schema_id
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.partitions AS p
ON i.object_id = p.object_id
AND i.index_id = p.index_id
Expand Down Expand Up @@ -1753,7 +1754,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
) AS os
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.tables AS t
ON os.object_id = t.object_id
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
ON os.object_id = v.object_id
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.schemas AS s
ON ISNULL(t.schema_id, v.schema_id) = s.schema_id
Expand Down Expand Up @@ -1961,11 +1962,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
)
THEN 0
END
FROM ' + QUOTENAME(@current_database_name) + N'.sys.indexes AS i
FROM ' + QUOTENAME(@current_database_name) + N'.sys.indexes AS i
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.tables AS t
ON i.object_id = t.object_id
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
ON i.object_id = v.object_id
ON i.object_id = t.object_id
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
ON i.object_id = v.object_id
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.schemas AS s
ON ISNULL(t.schema_id, v.schema_id) = s.schema_id
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.index_columns AS ic
Expand Down Expand Up @@ -2157,9 +2158,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
reserved_row_overflow_gb = SUM(ps.row_overflow_reserved_page_count) * 8. / 1024. / 1024.0, /* Convert directly to GB */
p.data_compression_desc,
i.data_space_id
FROM ' + QUOTENAME(@current_database_name) + N'.sys.indexes AS i
FROM ' + QUOTENAME(@current_database_name) + N'.sys.indexes AS i
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.tables AS t
ON i.object_id = t.object_id
ON i.object_id = t.object_id
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
ON i.object_id = v.object_id
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.schemas AS s
Expand Down Expand Up @@ -6541,7 +6542,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
)
)
BEGIN
WITH
WITH
empty_databases AS
(
SELECT
Expand Down
Loading
Loading