Skip to content

Commit 694669f

Browse files
Ajit Pratap Singhclaude
authored andcommitted
feat(advisor): add OPT-009 through OPT-020 optimization advisor rules (#453)
Expand the query advisor from 8 to 20 built-in rules. Each new rule implements the Rule interface (ID, Name, Description, Analyze) and is registered in DefaultRules(). All rules are stateless and safe for concurrent use. Written with TDD: failing tests first, then implementation. New rules: - OPT-009: Correlated subquery in SELECT list (N+1 pattern) - OPT-010: HAVING without GROUP BY (logic error / full-table aggregate) - OPT-011: Redundant ORDER BY in CTE without LIMIT (ignored by most DBs) - OPT-012: CAST/CONVERT wrapping a column in WHERE (prevents index use) - OPT-013: Three+ OR equality conditions on same column -> suggest IN (...) - OPT-014: NOT IN (subquery) NULL risk -> suggest NOT EXISTS - OPT-015: ORDER BY without LIMIT/FETCH/TOP sorts full result set - OPT-016: Column aliases defined in SELECT but unused in ORDER BY/HAVING - OPT-017: UNION (non-ALL) deduplication overhead -> suggest UNION ALL - OPT-018: COUNT(DISTINCT col) overhead -> verify DISTINCT is necessary - OPT-019: Subquery nesting depth >3 levels -> suggest CTEs - OPT-020: Explicit CROSS JOIN without condition (cartesian product) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ba4e21d commit 694669f

4 files changed

Lines changed: 1297 additions & 2 deletions

File tree

0 commit comments

Comments
 (0)