Skip to content

Commit 4d234e1

Browse files
2 parents 59b204f + 95a2551 commit 4d234e1

10 files changed

Lines changed: 6488 additions & 1978 deletions

File tree

Install-All/DarlingData.sql

Lines changed: 6146 additions & 1636 deletions
Large diffs are not rendered by default.

Presentations/Parameters/00 Demo.sql

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

Presentations/Parameters/02 PSPO Oddities.sql

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ ORDER BY
4747
Any value that appears fewer than 100 times (according to
4848
statistics) is considered very uncommon.
4949
50-
That means that if the *least* common value appears 100 times,
51-
it will *not* be considered very uncommon and will get the
50+
That means that if the *least* common value appears 100 times,
51+
it will *not* be considered very uncommon and will get the
5252
'everything else' variant.
5353
54-
Only values that don't appear in the histogram or are otherwise
55-
estimated (between steps) to match fewer than 100 times would
54+
Only values that don't appear in the histogram or are otherwise
55+
estimated (between steps) to match fewer than 100 times would
5656
trigger the 'very uncommon' variant in that scenario.
5757
5858
1. Very uncommon = fewer than 100 times
@@ -64,23 +64,23 @@ trigger the 'very uncommon' variant in that scenario.
6464

6565
/*Some heuristics stuff*/
6666
SELECT
67-
EqualityLow =
67+
EqualityLow =
6868
MIN(dss.equality_rows),
69-
EqualityHigh =
69+
EqualityHigh =
7070
MAX(dss.equality_rows),
7171
IsEligible =
72-
CASE
73-
WHEN MAX(dss.equality_rows) >
72+
CASE
73+
WHEN MAX(dss.equality_rows) >
7474
MIN(dss.equality_rows) * 100000
7575
THEN 'Yes'
7676
ELSE 'No'
7777
END,
78-
VeryUncommon =
78+
VeryUncommon =
7979
'< 100',
80-
VeryCommon =
80+
VeryCommon =
8181
POWER
8282
(
83-
10,
83+
10,
8484
FLOOR
8585
(
8686
LOG10
@@ -103,7 +103,7 @@ WHERE c.Score = @Score;
103103
N'@Score integer',
104104
0;
105105

106-
/*
106+
/*
107107
Optional extra examples (might be mundane)
108108
*/
109109

@@ -163,9 +163,9 @@ WHERE c.Id BETWEEN 1 AND 167991
163163
';
164164

165165

166-
/*
166+
/*
167167
Make sure you set this up to be repeatable 4 u.
168-
With DOP 1 FULLSCAN stats on Comments, I found
168+
With DOP 1 FULLSCAN stats on Comments, I found
169169
the tipping point to be (163769, 163770)
170170
171171
*/
@@ -234,12 +234,12 @@ N'
234234
@Score3 integer,
235235
@Score4 integer
236236
',
237-
0,
238-
0,
237+
0,
238+
0,
239239
0,
240240
0;
241241

242-
/*
242+
/*
243243
Also variant 27, just more compact:
244244
245245
*/
@@ -280,7 +280,7 @@ WHERE @Score = c.Score
280280
N'@Score integer',
281281
0;
282282

283-
/*
283+
/*
284284
The other main reason you might not see PSPO
285285
is a compilation time exceeding 1000ms.
286286

sp_HealthParser/sp_HealthParser.sql

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2804,7 +2804,7 @@ AND ca.utc_timestamp < @end_date';
28042804
'.'
28052805
ELSE 'no cpu issues found!'
28062806
END
2807-
2807+
28082808
RAISERROR('No scheduler data found', 0, 0) WITH NOWAIT;
28092809
END;
28102810
END;
@@ -2831,7 +2831,7 @@ AND ca.utc_timestamp < @end_date';
28312831
sd.hasDeadlockedSchedulersOccurred,
28322832
sd.didBlockingOccur
28332833
FROM #scheduler_details AS sd';
2834-
2834+
28352835
/* Add the WHERE clause only for table logging */
28362836
IF @log_to_table = 1
28372837
BEGIN
@@ -2848,28 +2848,28 @@ AND ca.utc_timestamp < @end_date';
28482848
'{date_column}',
28492849
'event_time'
28502850
);
2851-
2851+
28522852
IF @debug = 1
28532853
BEGIN
28542854
PRINT @mdsql_execute;
28552855
END;
2856-
2856+
28572857
EXECUTE sys.sp_executesql
28582858
@mdsql_execute,
28592859
N'@max_event_time datetime2(7) OUTPUT',
28602860
@max_event_time OUTPUT;
2861-
2861+
28622862
SET @dsql += N'
28632863
WHERE sd.event_time > @max_event_time';
28642864
END;
2865-
2865+
28662866
/* Add the ORDER BY clause */
28672867
SET @dsql += N'
28682868
ORDER BY
28692869
sd.event_time DESC
28702870
OPTION(RECOMPILE);
28712871
';
2872-
2872+
28732873
/* Handle table logging */
28742874
IF @log_to_table = 1
28752875
BEGIN
@@ -2890,30 +2890,30 @@ AND ca.utc_timestamp < @end_date';
28902890
didBlockingOccur
28912891
)' +
28922892
@dsql;
2893-
2893+
28942894
IF @debug = 1
28952895
BEGIN
28962896
PRINT @insert_sql;
28972897
END;
2898-
2898+
28992899
EXECUTE sys.sp_executesql
29002900
@insert_sql,
29012901
N'@max_event_time datetime2(7)',
29022902
@max_event_time;
29032903
END;
2904-
2904+
29052905
/* Execute the query for client results */
29062906
IF @log_to_table = 0
29072907
BEGIN
29082908
IF @debug = 1
29092909
BEGIN
29102910
PRINT @dsql;
29112911
END;
2912-
2912+
29132913
EXECUTE sys.sp_executesql
29142914
@dsql;
29152915
END;
2916-
END;
2916+
END;
29172917
END;/*End CPU*/
29182918

29192919
/*Grab memory details*/

sp_HumanEvents/sp_HumanEventsBlockViewer.sql

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ BEGIN
948948
JOIN sys.dm_xe_session_targets AS t
949949
ON s.address = t.event_session_address
950950
WHERE s.name = @session_name
951-
ORDER BY
951+
ORDER BY
952952
t.target_name
953953
OPTION(RECOMPILE);
954954
END;
@@ -962,7 +962,7 @@ BEGIN
962962
JOIN sys.dm_xe_database_session_targets AS t
963963
ON s.address = t.event_session_address
964964
WHERE s.name = @session_name
965-
ORDER BY
965+
ORDER BY
966966
t.target_name
967967
OPTION(RECOMPILE);
968968
END;
@@ -1163,7 +1163,7 @@ BEGIN
11631163
CROSS APPLY x.x.nodes('/RingBufferTarget/event') AS e(x)
11641164
WHERE e.x.exist('@name[ .= "blocked_process_report"]') = 1
11651165
AND e.x.exist('@timestamp[. >= sql:variable("@start_date") and .< sql:variable("@end_date")]') = 1
1166-
ORDER BY
1166+
ORDER BY
11671167
event_timestamp DESC
11681168
) AS most_recent
11691169
OPTION(RECOMPILE);
@@ -1195,7 +1195,7 @@ BEGIN
11951195
CROSS APPLY x.x.nodes('/event') AS e(x)
11961196
WHERE e.x.exist('@name[ .= "blocked_process_report"]') = 1
11971197
AND e.x.exist('@timestamp[. >= sql:variable("@start_date") and .< sql:variable("@end_date")]') = 1
1198-
ORDER BY
1198+
ORDER BY
11991199
event_timestamp DESC
12001200
) AS most_recent
12011201
OPTION(RECOMPILE);
@@ -1293,7 +1293,7 @@ BEGIN
12931293
event_timestamp = w.x.value('(//@timestamp)[1]', 'datetime2')
12941294
FROM #sp_server_diagnostics_component_result AS wi
12951295
CROSS APPLY wi.sp_server_diagnostics_component_result.nodes('//event') AS w(x)
1296-
ORDER BY
1296+
ORDER BY
12971297
event_timestamp DESC
12981298
) AS most_recent
12991299
OPTION(RECOMPILE);
@@ -2156,7 +2156,7 @@ WITH
21562156
varchar(400),
21572157
blocking_desc +
21582158
' </* ' +
2159-
blocked_desc
2159+
blocked_desc
21602160
)
21612161
FROM #blocking AS b
21622162
WHERE NOT EXISTS
@@ -2902,26 +2902,26 @@ BEGIN
29022902
SELECT
29032903
check_id = -1,
29042904
database_name = N'erikdarling.com',
2905-
object_name =
2906-
N'sp_HumanEventsBlockViewer version ' +
2907-
CONVERT(nvarchar(30), @version) +
2905+
object_name =
2906+
N'sp_HumanEventsBlockViewer version ' +
2907+
CONVERT(nvarchar(30), @version) +
29082908
N'.',
29092909
finding_group = N'https://code.erikdarling.com',
2910-
finding =
2911-
N'blocking events from ' +
2912-
CONVERT(nvarchar(30), @actual_start_date, 126) +
2913-
N' to ' +
2914-
CONVERT(nvarchar(30), @actual_end_date, 126) +
2915-
N' (' + CONVERT(nvarchar(30), @actual_event_count) +
2916-
N' total events' +
2917-
CASE
2918-
WHEN @max_blocking_events > 0
2919-
AND @actual_event_count >= @max_blocking_events
2920-
THEN N', limited to most recent ' +
2921-
CONVERT(nvarchar(30), @max_blocking_events) +
2922-
N')'
2923-
ELSE N')'
2924-
END +
2910+
finding =
2911+
N'blocking events from ' +
2912+
CONVERT(nvarchar(30), @actual_start_date, 126) +
2913+
N' to ' +
2914+
CONVERT(nvarchar(30), @actual_end_date, 126) +
2915+
N' (' + CONVERT(nvarchar(30), @actual_event_count) +
2916+
N' total events' +
2917+
CASE
2918+
WHEN @max_blocking_events > 0
2919+
AND @actual_event_count >= @max_blocking_events
2920+
THEN N', limited to most recent ' +
2921+
CONVERT(nvarchar(30), @max_blocking_events) +
2922+
N')'
2923+
ELSE N')'
2924+
END +
29252925
N'.',
29262926
1;
29272927

@@ -3751,8 +3751,8 @@ BEGIN
37513751
SELECT
37523752
check_id = 2147483647,
37533753
database_name = N'erikdarling.com',
3754-
object_name =
3755-
N'sp_HumanEventsBlockViewer version ' +
3754+
object_name =
3755+
N'sp_HumanEventsBlockViewer version ' +
37563756
CONVERT(nvarchar(30), @version) + N'.',
37573757
finding_group = N'https://code.erikdarling.com',
37583758
finding = N'thanks for using me!',

sp_IndexCleanup/sp_IndexCleanup.sql

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,12 +1418,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14181418
ELSE 0
14191419
END
14201420
FROM ' + QUOTENAME(@current_database_name) + N'.sys.indexes AS i
1421-
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.tables AS t
1421+
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.tables AS t
14221422
ON i.object_id = t.object_id
1423-
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
1423+
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
14241424
ON i.object_id = v.object_id
14251425
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.schemas AS s
1426-
ON ISNULL(t.schema_id, v.schema_id) = s.schema_id
1426+
ON ISNULL(t.schema_id, v.schema_id) = s.schema_id
14271427
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.partitions AS p
14281428
ON i.object_id = p.object_id
14291429
AND i.index_id = p.index_id
@@ -1975,7 +1975,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19751975
) AS os
19761976
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.tables AS t
19771977
ON os.object_id = t.object_id
1978-
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
1978+
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
19791979
ON os.object_id = v.object_id
19801980
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.schemas AS s
19811981
ON ISNULL(t.schema_id, v.schema_id) = s.schema_id
@@ -2183,11 +2183,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21832183
)
21842184
THEN 0
21852185
END
2186-
FROM ' + QUOTENAME(@current_database_name) + N'.sys.indexes AS i
2186+
FROM ' + QUOTENAME(@current_database_name) + N'.sys.indexes AS i
21872187
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.tables AS t
2188-
ON i.object_id = t.object_id
2189-
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
2190-
ON i.object_id = v.object_id
2188+
ON i.object_id = t.object_id
2189+
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
2190+
ON i.object_id = v.object_id
21912191
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.schemas AS s
21922192
ON ISNULL(t.schema_id, v.schema_id) = s.schema_id
21932193
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.index_columns AS ic
@@ -2379,9 +2379,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23792379
reserved_row_overflow_gb = SUM(ps.row_overflow_reserved_page_count) * 8. / 1024. / 1024.0, /* Convert directly to GB */
23802380
p.data_compression_desc,
23812381
i.data_space_id
2382-
FROM ' + QUOTENAME(@current_database_name) + N'.sys.indexes AS i
2382+
FROM ' + QUOTENAME(@current_database_name) + N'.sys.indexes AS i
23832383
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.tables AS t
2384-
ON i.object_id = t.object_id
2384+
ON i.object_id = t.object_id
23852385
LEFT JOIN ' + QUOTENAME(@current_database_name) + N'.sys.views AS v
23862386
ON i.object_id = v.object_id
23872387
JOIN ' + QUOTENAME(@current_database_name) + N'.sys.schemas AS s
@@ -6988,7 +6988,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
69886988
)
69896989
)
69906990
BEGIN
6991-
WITH
6991+
WITH
69926992
empty_databases AS
69936993
(
69946994
SELECT

0 commit comments

Comments
 (0)