Skip to content

Commit a721a16

Browse files
ajitpratap0Ajit Pratap Singhclaude
authored
feat(advisor): add OPT-009 through OPT-020 optimization advisor rules (#453) (#464)
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: Ajit Pratap Singh <ajitpratapsingh@Ajits-Mac-mini-2655.local> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ba4e21d commit a721a16

File tree

4 files changed

+1297
-2
lines changed

4 files changed

+1297
-2
lines changed

0 commit comments

Comments
 (0)