Skip to content

Updates_20261201 - Plans, Trains and Automobiles - #965

Merged
erikdarlingdata merged 124 commits into
mainfrom
dev
Nov 23, 2026
Merged

erikdarlingdata merged 124 commits into
mainfrom
dev

Conversation

@erikdarlingdata

Copy link
Copy Markdown
Owner

This release adds @plan_parsing to sp_QuickieStore. With @plan_parsing = 1, the procedure reads the plans in Query Store and reports plan findings. Examples are eager index spools, missing indexes and predicates that cannot use a seek. sp_QuickieStore with @get_all_databases = 1 no longer stops when one database is unreadable. A round of reviews fixed smaller problems in nine procedures and in the helper scripts.

Changes in behavior

sp_QuickieStore: plan parsing

@plan_parsing bit = 0 is new and opt-in. With @plan_parsing = 0, nothing changes. With @plan_parsing = 1, the procedure converts each plan to XML once and reads the XML into temp tables. Then 19 rules run over the temp tables as plain T-SQL.

  • The procedure returns one extra result set after the other results. It has one row for each plan and rule, with the columns database_name, query_id, plan_id, rule_id, rule_name, finding, object_name, node_ids. finding explains the problem in a sentence. node_ids lists the plan operators, for example 4, 7, 12 and 3 more.
  • The rules are numbered. Rule 0 reports a plan that was not checked, because Query Store has no plan text or the plan will not convert to XML.
  • Rules 1 to 4: eager index spool, serial plan, scalar UDF, lookup with predicate.
  • Rules 5 to 7: NOT IN on nullable column, implicit conversion prevents seek, missing index request.
  • Rules 8 to 10: late filter, scan with residual predicate, non-SARGable predicate.
  • Rules 11 to 13: multi-statement table-valued function, TOP over scan, many-to-many merge join.
  • Rules 14 to 16: table variable, remote query, wide DML.
  • Rules 17 to 19: Standard Edition batch mode DOP 2, scan on inner side of nested loops, long compile.
  • Rule 1 writes a CREATE INDEX statement in the finding. For a spool on a table variable, it suggests an inline index in the DECLARE, or a temp table.
  • Some findings need a value to reach a threshold. The thresholds are 1 second of average CPU, duration or compile time, and 1,000 executions a day. A scan must cover 1,000,000 rows, and a wide DML statement must maintain 5 indexes. They are @pp_* variables at the top of the plan parsing section in the procedure. They are starting values.
  • Large numbers in the finding text have thousands separators. (sp_QuickieStore: thousands separators in @plan_parsing finding text #932)
  • The procedure rejects @plan_parsing = 1 together with @find_high_impact, @find_parameter_sensitive, regression mode or @log_to_table. It raises a severity 11 error.
  • On the author's test server, @plan_parsing = 1 added CPU time to the same call. It added 1.1 to 1.4 seconds at @top = 10, 5.2 to 10.8 seconds at @top = 100, and 30 to 32 seconds at @top = 500. The plans came from three databases of different sizes. The cost grows with the number of plans, so keep @top small. (sp_QuickieStore: add @plan_parsing plan findings #931, sp_QuickieStore: @plan_parsing review patches 2026-10-27 #934)
  • A set of 24 review patches made the passes read less XML and made the findings more exact. In particular, rule 8 skips bitmap probes and filters on aggregates and windows. Rule 3 blames a scalar UDF for a serial plan only when the plan says the UDF caused it. (sp_QuickieStore: @plan_parsing review patches 2026-10-27 #934)

Known limits:

  • Rule 5 runs only when the query text has NOT IN or <> ALL. It misses a NOT IN inside a view or a function.
  • The thresholds are fixed starting values. To change them, edit the @pp_* variables.
  • Rule 2 and rule 17 read the MAXDOP settings when the procedure runs, not when the plan compiled. A finding that depends on MAXDOP can be wrong, and the text says "likely".
  • The inserts into the plan parsing temp tables use TABLOCK and MAXDOP 1, so they run serial. The reason is that parallel startup cost more than these small inserts.
  • With @debug = 1, the dump of #plan_edges is partial. The edge pass opens only the statements whose rules read edges.
  • Not tested: rules 15 and 17, and rule 14 on real plans. Also not tested: Azure SQL Database, Azure SQL Managed Instance, and a Resource Governor group with max_dop 1. Rule 8 on a Hash Match semi join probe has no test fixture.

sp_QueryReproBuilder

sp_HumanEvents and sp_HumanEventsBlockViewer

  • The procedures read the blocked process attributes in one pass, and they read the event values in one pass with a PIVOT. The BlockViewer reads the reports once into a staging table before it logs them. The test used 3,032 blocked process reports. The CPU of sp_HumanEventsBlockViewer went from 46,545 to 24,893 ms with event_file. It went from 46,798 to 26,624 ms with a ring buffer, and from 45,109 to 23,250 ms with a table. The same run of sp_HumanEvents with blocking went from 44,734 to 25,062 ms. The logging insert and update went from 31,641 to 9,563 ms. These are the author's numbers. The staged logging insert also asks for a much smaller memory grant. (sp_HumanEventsBlockViewer, sp_HumanEvents: review patches 2026-10-27 #935)
  • The result sets have the same rows and columns as before. (sp_HumanEventsBlockViewer, sp_HumanEvents: review patches 2026-10-27 #935)
  • The name compares in the logging step use the collation of the database that holds the procedure. The last_updated value in #human_events_worker no longer moves on a pass that only inserts. It appears only in the @debug output. (sp_HumanEventsBlockViewer, sp_HumanEvents: review patches 2026-10-27 #935)

sp_PressureDetector

Scripts and repo changes


All ten bundled procedures move to minor version .12, with @version_date 20261201. That includes sp_PerfCheck, which has no change, and sp_IndexCleanup, which has a help text change. sp_QueryStoreCleanup moves to 1.12 and TestBackupPerformance moves to 1.2. ProtectSession is unchanged, because its change is a comment.

🤖 Generated with Claude Code

https://claude.ai/code/session_01M98owbb9iKsAUWvSpjCFTz

erikdarlingdata and others added 30 commits October 26, 2026 22:46
Adds a plan_parsing_tests group to the harness (one fixture query per
testable rule, quiet-case and rejection checks) and documents the
parameter and the plan findings result set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
… findings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
…s plus rule 0)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
… faster shred; tests use server local time for the window

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
…rdware, print plan operators on a failed rule check, add review regression tests

Rule 18: a 1 GB, 4 core container puts a lazy Table Spool over the scan; QUERYTRACEON 8690, FORCE ORDER and MAXDOP 1 pin the direct inner scan.
Rule 8: SQL Server 2025 turns LEFT JOIN + IS NULL into an anti semi join; an OR with an outer-side column keeps the Filter.
New regression fixtures: rule 1 (range seek, computed output), rule 4 (two fetched columns), rule 5 (NOT NULL keys with unrelated IS NULL, NOT EXISTS, comment), rule 2 (comment), rule 12 (NOT IN null check Top), rule 8 (catalog view), rule 0 (IF condition), STATIC and KEYSET cursors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
…xtures, 273 assertions; cursor check wording

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
…pool/lookup column lists, rule 5 structure, MAXDOP settings, fold, sys schema)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
…tyle, README, tests follow-ups)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
…and seek shapes plus text gate, cursor rule 2, debug early exit, rule 1 coverage, table variables, rule 18 spools, fold)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
…1, read seeks only in anti join plans, README and test notes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
…per QueryPlan

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
…n-parsing

sp_QuickieStore: add @plan_parsing plan findings
Use FORMAT(x, 'N0') for CPU ms, table cardinality and compile ms in the
rule 2, 9, 18 and 19 findings. Adds a rule 9 assertion for 1,000,000 rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UT4xePKcEVUmyzwGYSEuqU
…er-format

sp_QuickieStore: thousands separators in @plan_parsing finding text
…only where it exists

Slow statement: the INSERT into #plan_operators, the .//RelOp pass.
It read @TableCardinality from every RelOp. Only scans, seeks and lookups
carry that attribute, and a .value() for an attribute that is missing reads
the whole subtree of the RelOp. For the root RelOp that is the whole plan,
so the pass cost grows with plan size times operator count.

Evidence (500 plans, 38 MB of plan xml, 14,167 RelOps, one pass each, CPU ms):
.//RelOp with no .value() 359; one present attribute 797; four 2,047;
the same four plus TableCardinality 5,765; TableCardinality alone 4,047;
EstimateCPU (always present) alone 797.

The pass now reads TableCardinality in an OUTER APPLY that only runs for
operators whose PhysicalOp contains Scan, Seek or Lookup. Every rule that
uses table_cardinality reads it from a Clustered Index Scan, Index Scan or
Table Scan, so the rules see the same values. The only change in the
@debug dump of #plan_operators: a Nested Loops that represents a dynamic
seek also carries TableCardinality, and it is now NULL there.

Before/after, LargeDB, @top = 500, warm, median of 3, statement CPU and elapsed
from sp_statement_completed: 6,422 / 6,413 ms -> 2,984 / 2,982 ms.
Plan findings identical (SHA-256 over every column of every row, sorted on
database_name, plan_id, rule_id) on LargeDB, MediumDB and SmallDB at @top = 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…operator

Slow statement: the INSERT into #plan_objects. It shredded every Object
and went up to the operator with ../../@nodeid. The parent axis is the
most expensive thing an xml method can do here: ../../@nodeid alone from
every RelOp costs 12,500 ms CPU against 797 ms for @nodeid (500 plans,
14,167 RelOps).

The pass now shreds the RelOps that have an Object under their operator
element (.//RelOp[*/Object]), reads @nodeid there, and then the Objects
with */Object. An Object whose grandparent has a NodeId is an Object under
a RelOp's operator element, so the rows are the same ones, in the same
document order (checked: 4,822 rows both ways, EXCEPT empty in both
directions).

Before/after, LargeDB, @top = 500, warm, median of 3, statement CPU and elapsed
from sp_statement_completed: 7,828 / 7,828 ms -> 3,969 / 3,965 ms.
Plan findings identical (SHA-256 over every column of every row, sorted on
database_name, plan_id, rule_id) on LargeDB, MediumDB and SmallDB at @top = 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ind's own path

Slow statement: the INSERT into #plan_statements. Per plan it ran:
//Statements/*[self::StmtSimple or self::StmtCursor or self::StmtCond],
then (QueryPlan, CursorPlan/Operation/QueryPlan, Condition/QueryPlan) on
every statement, and ../@OperationType (parent axis) on every QueryPlan.

Evidence (500 plans, 38 MB of plan xml, CPU ms): //Statements/* 375;
the same with the three self:: tests 1,469; adding the QueryPlan child
path 1,906; adding the three-path union instead 2,704.

The pass now shreds //Statements/*, reads local-name() once per statement,
and each kind reads only its own path in a UNION ALL: StmtSimple reads
QueryPlan, StmtCond reads Condition/QueryPlan, and StmtCursor reads
CursorPlan/Operation and takes @OperationType from the Operation it is on,
then its QueryPlan. Per the showplan schema a QueryPlan can only sit at
those places, so the rows are the same. #plan_statements compared on every
column (qp_xml by SHA-256 of its text): no difference in either direction.

Before/after, LargeDB, @top = 500, warm, median of 3, statement CPU and elapsed
from sp_statement_completed: 6,047 / 6,069 ms -> 4,125 / 4,157 ms.
Plan findings identical (SHA-256 over every column of every row, sorted on
database_name, plan_id, rule_id) on LargeDB, MediumDB and SmallDB at @top = 500,
and on the tests' plan_parsing fixture queries, which include STATIC,
KEYSET and DYNAMIC cursors and an IF condition plan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d the stray attribute read

Slow statement: the INSERT into #plan_predicates. The RelOp path had a
second step, [*/*[self::Predicate or self::ProbeResidual]], and every
candidate read Filter/@StartupExpression. That test reads into the
operator's children, and for a Filter or an anti semi join those children
are the rest of the plan below it. StartupExpression is missing on every
candidate that is not a Filter, and a missing attribute makes .value()
read the whole subtree.

Now: the candidates are picked with the attribute tests only (one general
comparison for the PhysicalOp list), the predicate copy is made for each
candidate and an empty copy is dropped with .exist(N'*') = 1, which is the
test the path made, and StartupExpression is read in an OUTER APPLY that
only runs for a Filter. #plan_predicates compared on every column (pred_xml
by SHA-256 of its text): 1,527 rows, no difference in either direction.

Evidence (500 plans, CPU ms of this pass alone): as it was 5,797;
without the path test 3,860.

Before/after, LargeDB, @top = 500, warm, median of 3, statement CPU and elapsed
from sp_statement_completed: 6,000 / 6,005 ms -> 4,032 / 4,022 ms.
Plan findings identical (SHA-256 over every column of every row, sorted on
database_name, plan_id, rule_id) on LargeDB, MediumDB and SmallDB at @top = 500,
and on the tests' plan_parsing fixture queries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tements that have the operator

Slow statements: six passes that look for operators most plans do not
have, each reading every statement's whole plan:
the many-to-many merge join pass (.//Merge[@manytomany = "1"]), the
Top (1) pass, the lookup fetch columns pass, the eager index spool seek
and output column passes, and the anti semi join equality pass.

Each one now reads only the statements that have that operator, with the
same EXISTS over #plan_operators the anti join seek passes and the computed
spool column pass already use (the fetch pass uses the lookups that the
lookup pass found in #plan_specials). The path of each pass already
requires that operator, so the rows are the same.

LargeDB, @top = 500: of 500 statements, 65 have a merge join, 29 a Top,
134 a lookup, 21 an eager index spool, 14 an anti semi join.

Before/after, LargeDB, @top = 500, warm, median of 3, statement elapsed ms
from sp_statement_completed (CPU within 15 ms of elapsed):
merge join 739 -> 144, Top (1) 520 -> 75, lookup fetch columns 2,482 -> 2,167,
spool seek columns 1,287 -> 466, spool output columns 1,224 -> 422,
anti semi join equality 1,069 -> 169. Together 7,321 -> 3,443.
Plan findings identical (SHA-256 over every column of every row, sorted on
database_name, plan_id, rule_id) on LargeDB, MediumDB and SmallDB at @top = 500,
and on the tests' plan_parsing fixture queries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rs no plan has

Slow part: compilation, not execution. The procedure is WITH RECOMPILE and
every plan parsing statement has OPTION(RECOMPILE), so each one compiles on
every call. The xml statements take 20 to 120 ms each to compile. At @top = 10
the plan parsing statements ran for about 530 ms on LargeDB, and the time
between them (compiles and auto statistics, measured as the gap between one
sp_statement_completed and the next statement's start) was 1,076 ms.
The largest compiles were passes that returned no rows: the anti semi join
column passes (21, 106, 116 and 54 ms), the eager spool column passes
(24, 21 and 98 ms), the merge join and Top passes, and rules 1, 5, 12 and 18.

One SELECT over #plan_operators now sets a flag per operator kind (anti
semi join, left anti semi join, merge join, Top or TopN Sort, eager index
spool, nested loops), and a flag for lookups after the lookup pass. Each of
those passes and rules runs inside IF @pp_has_... = 1. A statement that is
skipped would have returned no rows, because its path or its join already
requires that operator, so #plan_* and the findings do not change. Most of
the diff is the re-indent inside the new IF blocks (git diff -w: 84 lines).

Before/after, batch CPU added by @plan_parsing = 1 over @plan_parsing = 0,
warm, median of 3, @top = 10: LargeDB 1,626 -> 1,110 ms, MediumDB 1,594 -> 1,437,
SmallDB 1,687 -> 1,546. @top = 100: no change (every flag is set there).
Gap between statements in the plan parsing section, LargeDB @top = 10:
1,076 -> 586 ms.
Plan findings identical (SHA-256 over every column of every row, sorted on
database_name, plan_id, rule_id) on LargeDB, MediumDB and SmallDB at @top = 10,
100 and 500, and on the tests' plan_parsing fixture queries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… rule reads edges for

Slow statement: the INSERT into #plan_edges, after the other fixes the
most expensive pass. Listing the child RelOps of a RelOp (*/RelOp) has to
read through the whole subtree of the first child to reach the second, so
the pass costs the sum of all subtree sizes. No xml path avoids that.

The edges are only read by the rules for: a Top or TopN Sort (rule 12,
through #plan_relations), an anti semi join (rule 5), a table variable scan
estimated at one row (rule 14, through #plan_relations), and a scan of
@pp_scan_rows or more in a plan with a Nested Loops join (rule 18). The pass
now opens only those statements. It moves below the scan marking, because
the gate reads is_scan, obj_table and table_cardinality.

This is a trade, not a free fix. In the @debug dump, #plan_edges has no rows
for the other statements, and #plan_relations has NULL parents for the large
scans in them (no rule reads those). A new rule that reads #plan_edges has
to be added to the gate. Drop this commit if that coupling is not wanted.

LargeDB, @top = 500: 227 of 500 statements opened, 8,366 of 13,667 edges kept.

Before/after, LargeDB, @top = 500, warm, median of 3, statement CPU and elapsed
from sp_statement_completed: 5,985 / 5,994 ms -> 3,703 / 3,692 ms.
Plan findings identical (SHA-256 over every column of every row, sorted on
database_name, plan_id, rule_id) on LargeDB, MediumDB and SmallDB at @top = 500,
and on the tests' plan_parsing fixture queries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iminated" to the client

Every @plan_parsing = 1 run that had a finding with no node id or no object
(rules 2, 3, 6, 7 and 19 never have a node id) sent Msg 8153, "Warning: Null
value is eliminated by an aggregate or other SET operation.", to the client.
The @plan_parsing = 0 path sends none. Found with an error_reported event
filtered to error 8153: it fired inside the final fold SELECT.

Three aggregates in the fold saw NULLs: COUNT_BIG(DISTINCT object_name),
COUNT_BIG(DISTINCT ... + node_id), and MIN(node_id) for the finding order.
The two counts are now correlated subqueries that skip the NULL rows first
(a count of distinct non-NULL values, as before, 0 when there are none), and
the MIN is NULLIF(MIN(ISNULL(node_id, 2147483647)), 2147483647), which is the
lowest node id, or NULL when the finding has none, as before.

Not fixed here: rule 16 still raises the warning when a plan has a cursor
worktable insert (the worktable Object has no Table, so MIN/MAX(obj_table)
sees NULL). Real plans on the test server had none; the tests' cursor
fixtures do.

Plan findings identical (SHA-256 over every column of every row, sorted on
database_name, plan_id, rule_id) on LargeDB, MediumDB and SmallDB at @top = 10,
100 and 500, and on the tests' plan_parsing fixture queries. Msg 8153 count
per run on those nine real-data runs: 1 -> 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on computed values

Rule 8 (late filter) reported Filter operators the optimizer adds on purpose.
Two kinds are now left out:
- a predicate that only probes an optimizer bitmap, with the same text test
  rule 9 already uses: PROBE([Opt_Bitmap...], ...) and nothing else;
- a predicate that reads a column another operator computed (a ColumnReference
  with no Table that is not a parameter, a variable or the bitmap a PROBE reads).
  Such a Filter compares with an aggregate or a join result, so it cannot be
  applied before that operator.
The second test is a new flag, pred_expr_col, read in the same pass as the
other predicate flags and shown in the @debug dump of #plan_predicates.

Evidence, plan xml read for each kind:
- removed, bitmap: a Filter over a Clustered Index Seek whose whole predicate
  is PROBE([Opt_Bitmap1198],[t1].[c1]);
- removed, computed value: [t2].[c2]<>isnull([Expr1004],(0)) over a Merge Join,
  where Expr1004 is a SUM() from a Stream Aggregate under the join;
- kept: [t3].[c3] IS NULL over a Hash Match right outer join.

Rule 8 findings at @top = 500, before -> after.
Raw rows (one per Filter): LargeDB 184 -> 45, MediumDB 154 -> 23, SmallDB 547 -> 29.
Returned rows (one per plan): LargeDB 146 -> 33, MediumDB 137 -> 21, SmallDB 301 -> 24.
The raw rows after are exactly the rows before minus the Filters an independent
reader of the plan xml marks as bitmap-only (119 / 100 / 258) or as reading a
computed value (20 / 31 / 260): no row missing, no row extra. No other rule
changed. The rule 8 positive fixture still fires; the new negative fixture
r8expr is quiet.

Tests: a fixture query (r8expr) and an assertion that rule 8 stays quiet for it.
README: rule 8 row describes the two exclusions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… skips system tables

Rule 4 (lookup with predicate) told you to add the fetched columns to the
index, but left out the columns of the looked-up table that the lookup's own
predicate reads. Those are the columns that remove the lookup. When the lookup
fetched nothing, the text said "It fetches <columns not listed>". It also fired
for lookups into system tables, which the scan rules already skip.

Now:
- the lookup pass keeps two small copies per lookup in #plan_specials, its
  DefinedValues and its Predicate (not in the @debug dump);
- the fetch columns are shredded from the DefinedValues copy instead of from the
  plans, and a new 'lkpred' role in #plan_columns holds the predicate's columns;
- the finding reads "It fetches [a], [b] and filters on [c]: add them ...",
  or "It fetches no other columns and filters on [c]: ...". A predicate column
  that is also fetched is listed once, in the fetch list. Only columns of the
  looked-up table count, not the outer columns the predicate compares with;
- lookups into schema [sys] are skipped.

Evidence: a lookup with the predicate [t].[a]=[@p] AND [t].[b] IS NOT NULL
that fetches [c] now reads "It fetches [c] and filters on [a], [b]". The
fixture's lookup into [sys].[sysschobjs] no longer fires.

Rule 4 findings at @top = 500: rows changed only in their text, LargeDB 66 of 69,
MediumDB 42 of 46, SmallDB 30 of 31 (the others already fetch every predicate
column). In all 169 findings in those rows the fetch list is unchanged, word for
word. "<columns not listed>": 54 -> 0. No rows added or removed, no other rule
changed. Fixture: 5 rows changed text, 1 removed (the system table lookup).

Timing, LargeDB @top = 500, statement elapsed ms: lookup pass 1,468 -> 2,086
(the two copies), fetch columns pass 2,159 -> 26 (reads the copies), new
predicate columns pass 20. Together 3,627 -> 2,132.

Tests: rule 4 must list the predicate column of the looked-up table, and stay
quiet for the system table lookup. README: rule 4 row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ool on a table variable

Rule 1 (eager index spool) scripted CREATE INDEX for every spool. For a spool
over a table variable that is not valid T-SQL: the finding read
"CREATE INDEX [ix_@t_spool] ON @t (...)". A table variable can only get an
index in its DECLARE.

When the spool's seek columns belong to a table variable (the plan shows the
table as @name or [@name]), the finding now reads, for the tests' fixture:
"The optimizer builds a temporary index on the table variable @Tv1 every time
this runs. A table variable cannot take CREATE INDEX: declare it with the
index, INDEX [ix_tv1_spool] ([a]) INCLUDE ([b]) in its DECLARE, or use a temp
table with that index." The key and include lists are built as before. The
inline INDEX ... INCLUDE form was checked to compile in a table variable
DECLARE on the test server (SQL Server 2022).

Findings at @top = 500: rule 1 text changed in 2 rows on LargeDB and 1 on
MediumDB, the three spools over a table variable (plan xml: the spool's
SeekPredicateNew columns have Table="@..." and no Database or Schema).
No rows added or removed, no other rule changed.

Tests: a fixture query (r1tv) with an eager index spool over a table variable,
and an assertion that its finding has the inline INDEX and no CREATE INDEX.
README: rule 1 row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pile time

Rule 2 (serial plan) reported MaxDOPSetToOne with "The server and database
MAXDOP are not 1, so MAXDOP 1 was asked for in the query, a Query Store hint
or a plan guide." It reads the settings as they are now. Query Store does not
keep the settings a plan compiled under, so a plan compiled while the server
or database MAXDOP was 1 got the wrong cause.

Evidence: the tests' fixture r2c has no hint. It compiles while the database
scoped MAXDOP is 1, which is then set back to 0. The finding named the query,
a hint or a plan guide, and the test "rule 2 flags MaxDOPSetToOne when server
and database MAXDOP are not 1" asserted that case.

The text is now: "The server and database MAXDOP are not 1 now, so unless
MAXDOP was 1 when the plan compiled, MAXDOP 1 was asked for in the query, a
Query Store hint or a plan guide." When to flag does not change.

Findings: the 2 MaxDOPSetToOne rows in the fixture changed text. At @top = 500
on LargeDB, MediumDB and SmallDB nothing changed (no MaxDOPSetToOne plan there
reaches the 1,000 ms CPU threshold).

Tests: the r2c comment no longer claims the MAXDOP 1 can only come from the
query, and a new assertion checks that the finding allows for MAXDOP 1 at
compile time. README: rule 2 row; tests README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the scan ran

Rule 18 (scan on inner side of nested loops) said the scan "can run once for
every row on the outer side" and told you to add an index. The rules use no
estimates, so the rule cannot know the outer side's row count. Its one hit at
@top = 500 on the test server's three databases is a scan whose outer side is
estimated at 1 row, with EstimateRebinds and EstimateRewinds of 0 (it runs once).

The text is now conditional: "... is on the inner side of a Nested Loops join,
so it can run again for each row from the outer side. The plan cannot show how
many times it ran: if the outer side returns more than a few rows, an index on
the join columns lets it seek instead." When to flag does not change.

Findings at @top = 500: rule 18 text changed in its 1 row on MediumDB. Nothing
else changed on LargeDB, MediumDB or SmallDB. Fixture: 4 rule 18 rows changed text.

Tests: an assertion on the wording. README: rule 18 row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… eliminated" for cursor worktables

The plan of a KEYSET or DYNAMIC cursor inserts into a cursor worktable. Its
Object has an Index ([CWT_PrimaryKey]) and no Table, so #plan_dml_indexes gets
a row with obj_table NULL, and MIN(obj_table) and MAX(obj_table) in rule 16
sent Msg 8153 to the client. Found with an error_reported event filtered to
error 8153 on the tests' cursor fixtures; it fired right after the rule 16 INSERT.

The two values are now correlated subqueries over the rows that have a table
name, which gives the same MIN and MAX as before (NULL when no row has one).
The index count still includes the worktable index, as before.

Msg 8153 per run on the tests' fixture queries: 1 -> 0. Findings unchanged on
the fixture and on LargeDB, MediumDB and SmallDB at @top = 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
erikdarlingdata and others added 28 commits November 13, 2026 03:37
…ts: owner, docs and manifest fixes

- Ola Stats Only Job: look up the job owner with SUSER_SNAME(0x01) so a renamed sa works (same pattern as ClearTokenPerm Agent Job); README and header updated.
- Clear Token Perm: README and ClearTokenPerm.sql header say to install in master, which is where the Agent job runs it.
- Inflate Security Cache demo: cache size now pages_kb / 1024. / 1024. (GB), matching ClearTokenPerm.
- ProtectSession: README and comment now say only the two KILL statements have their own TRY/CATCH; any other error re-throws and ends the proc.
- Export-SqlResults: manifest.csv is written in a finally block so a severity 11-16 error no longer loses it (error still propagates); a statement with no result set no longer consumes a result set number.
- Export-SqlResults README: parameters shown as -Name, matching the param block.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M98owc3zzZNEpij3p49Bbe
…examples

WhatsUpLocks: only read locks in the current database (resource_database_id = DB_ID()), and make the self-exclusion NULL-safe so APPLICATION and METADATA locks are listed.
WhatsUpMemory: only count buffer pages cached for the current database.
WhatsUpIndexes: in_row_pages_mb uses in_row_reserved_page_count; add row_overflow_pages_mb so overflow pages stay reported.
README: fix the failing examples and describe the changed behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M98owc3zzZNEpij3p49Bbe
TestBackupPerformance, Inline Financial Functions: copy-only test backups, rate fixes
…nup, installers

- sp_HumanEvents README: the BlockViewer examples now name the real default session (keeper_HumanEvents_blocking) and point the custom-name example at the Setup session.
- sp_QuickieCache README and root README: relabel the @start_date example, which is not "today".
- sp_IndexCleanup: README, root README and @help now say @get_all_databases is not supported on Azure SQL Database (text-only, no version change).
- Root README: add an "Other scripts" index for six folders that had no entry.
- LICENSE.md: copyright years 2019-2026.
- sp_HumanEvents and sp_PressureDetector: document the sqlcmd installers; fix their usage text to the -v TargetDB="name" form that both sqlcmd flavors accept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M98owc3zzZNEpij3p49Bbe
Ola Stats Only Job, Clear Token Perm, ProtectSession, Export-SqlResults: owner, docs and manifest fixes
Helper Views: scope to current database, fix in-row pages and README examples
…ctness fixes

- Dynamic SQL Logging: log physical reads from r.reads (already physical) in both passes instead of reads - logical_reads, which went negative on a warm cache; drop unused variables.
- String Functions: strip_characters and strip_characters_cte count characters with DATALENGTH / 2 so trailing spaces are kept; README documents the kept-space behavior and error 6841 for control characters.
- SQL Debug Example: print loop advances @block_size so blocks no longer repeat a character; the faked long dynamic SQL is a quoted string literal so the default run executes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M98owc3zzZNEpij3p49Bbe
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M98owc3zzZNEpij3p49Bbe
Docs: README example fixes, folder index, Azure note for sp_IndexCleanup, installers
Dynamic SQL Logging, String Functions, SQL Debug Example: small correctness fixes
CI: least-privilege token, pinned go-sqlcmd, timeouts, concurrency, check naming
…line for --only multidb

The README said 397 checks in one place and "Expect 364 / 365 on 2017" in
another. The real counts from a green CI run on dev (b7fba0f) are 397 on SQL
Server 2022 and 2025, 396 on 2017 and 395 on 2019; the README now says so and
explains why the count changes with the version.

--only multidb now prints a "Total: N passed, M failed" line, like --only
plan_parsing, so repeated runs of the group can be counted.

The MultiDb "both databases return their queries" flake from 2026-10-23 is
already fixed on dev by ea8cf0c (markers folded by simple parameterization,
not a Query Store flush race), and every fixture already flushes, so no
fixture change is made here.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M98owc3zzZNEpij3p49Bbe
sp_QuickieStore tests: fix check counts in the README (MultiDb flake already fixed)
- .vs/: four Visual Studio per-user files committed in 2025-02. Added
  .vs/ to .gitignore so they don't come back, and dropped the file's BOM.
- _config.yml and CNAME: GitHub Pages is off and the CNAME domain does
  not resolve.
- image.png and image-1.png: empty files, referenced nowhere.
- todo.md: an old review checklist, linked from nowhere. It stays in
  git history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M98owc3zzZNEpij3p49Bbe
…d-files

Repo: remove unused tracked files, ignore .vs/
Docs: CI-built bundle, dev-latest, style guide pointer, issue template fixes
…941)

The memory broker section tested the broker notification against
RESOURCE_MEMPHYSICAL_LOW, a resource monitor value. A broker notification is
STABLE, GROW or SHRINK, so with @warnings_only = 1 no broker row could ever be
returned, even when SHRINK events existed. Keep a broker row under
@warnings_only = 1 only when the notification is SHRINK. The README row and
@help text now say so. The resource monitor filter in the memory conditions
section is correct and unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M98owc3zzZNEpij3p49Bbe
…ker-warnings

sp_HealthParser: @warnings_only filters memory broker rows on SHRINK (#941)
…quest

Run the branch check on pull_request, not pull_request_target
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H7GPrDup2EDE1v9D7jdVT4
main has #937 (a main-only copy of #939) plus the CI-built bundle commits.
#937 and dev's #939/#961 both edit .github/workflows/main-dev.yml, so the
dev -> main promotion conflicts there. Resolved by keeping dev's file: it
already has #937's change (#939) and also moves the branch check off
pull_request_target (#961). Install-All/DarlingData.sql and the reformatted
Presentations file come from main's CI build commits unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M98owbb9iKsAUWvSpjCFTz
Bump the ten bundled procs to .12 with date 20261201, sp_QueryStoreCleanup to 1.12 and TestBackupPerformance to 1.2. Fix the TABLOCK, index column list and CASE layout in sp_QuickieStore, int to integer in ClearTokenPerm, and let EffectiveAnnualInterestRate accept negative rates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M98owbb9iKsAUWvSpjCFTz
Merge main into dev before the Updates_20261201 promotion
Updates_20261201: version bumps and audit fixes
@erikdarlingdata
erikdarlingdata merged commit 3e0cd96 into main Nov 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant