Skip to content

Cursor-aware rules (#215 E1, E2, E3)#272

Merged
erikdarlingdata merged 1 commit intodevfrom
feature/cursor-rules-e1-e3
Apr 24, 2026
Merged

Cursor-aware rules (#215 E1, E2, E3)#272
erikdarlingdata merged 1 commit intodevfrom
feature/cursor-rules-e1-e3

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

  • E1: Rule 36 Dynamic Cursor — statement-level warning when CursorActualType is Dynamic. Recommends FAST_FORWARD / STATIC / KEYSET.
  • E3: Rule 37 Cursor Missing LOCAL — regex on DECLARE CURSOR statements. Links to Erik's blog.
  • E2: Rule 11 Scan With Predicate augmented with dynamic-cursor root-cause text when the statement is running inside a dynamic cursor.

Verified on Joe's `P7opX79MzB` plan. No false positives on existing plans.

Part of the v1.8.0 batch.

🤖 Generated with Claude Code

Rule 36 — Dynamic Cursor (E1): statement-level warning when CursorActualType
is "Dynamic". Dynamic cursors can't use many indexes because they must
tolerate data changes between fetches; recommends FAST_FORWARD / STATIC /
KEYSET as the usual fix.

Rule 37 — Cursor Missing LOCAL (E3): regex-scans statement text for
DECLARE <name> [qualifiers] CURSOR FOR without LOCAL in the qualifier list.
Default cursor scope is GLOBAL which bloats the plan cache — links to
Erik's blog post on OPENJSON cursor declarations.

Rule 11 augmentation (E2): when Scan With Predicate fires on a statement
whose CursorActualType is Dynamic, the message now points at the cursor as
the root cause instead of suggesting more indexes. Verified on Joe's plan
P7opX79MzB — the clustered-index-scan warning now reads "This query is
running inside a dynamic cursor, which can prevent index usage; changing
the cursor type often fixes scans like this without any indexing change."

No regressions on non-cursor plans (c1-c5.sqlplan, 20260415_1.sqlplan).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 5019883 into dev Apr 24, 2026
2 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/cursor-rules-e1-e3 branch April 24, 2026 19:50
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