areas/software/data-engineering/skills/sql-optimization/SKILL.md
# Skill: SQL Optimization ## When to load When writing complex queries, optimizing slow queries, designing indexes, or reviewing query performance. ## Core Patterns ```sql -- ✅ Column projection — never SELECT * SELECT user_id, created_at, total_amount FROM orders WHERE created_at >= '2026-01-01'; -- ✅ Partition pruning — filter on partition column first SELECT user_id, total_amount FROM orders WHERE order_date = '2026-01-15' -- partition filter first AND status = 'completed'; -- ❌ Func
npx skillsauth add sawrus/agent-guides areas/software/data-engineering/skills/sql-optimizationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
When writing complex queries, optimizing slow queries, designing indexes, or reviewing query performance.
-- ✅ Column projection — never SELECT *
SELECT user_id, created_at, total_amount FROM orders WHERE created_at >= '2026-01-01';
-- ✅ Partition pruning — filter on partition column first
SELECT user_id, total_amount
FROM orders
WHERE order_date = '2026-01-15' -- partition filter first
AND status = 'completed';
-- ❌ Function on indexed column defeats index
WHERE DATE(created_at) = '2026-01-15'
-- ✅ Range comparison preserves index
WHERE created_at >= '2026-01-15' AND created_at < '2026-01-16'
SELECT
user_id, order_date, amount,
SUM(amount) OVER (
PARTITION BY user_id ORDER BY order_date
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS cumulative_amount,
ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY order_date DESC) AS recency_rank
FROM orders;
-- Cluster keys on large tables (> 1 TB)
ALTER TABLE orders CLUSTER BY (order_date, status);
-- COPY INTO for bulk loads — never row-by-row INSERT
COPY INTO orders FROM @my_stage/orders/
FILE_FORMAT = (TYPE = PARQUET) MATCH_BY_COLUMN_NAME = CASE_INSENSITIVE;
testing
QA Expert for writing E2E tests, test scenarios, test plans, and ensuring test coverage quality.
development
Expert UI/UX design intelligence for creating distinctive, high-craft, and mobile-first interfaces. Focuses on premium aesthetics, touch-first ergonomics, and Flutter performance.
development
Code Review Expert for static analysis, security auditing, architecture review, and ensuring code quality standards.
development
Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep watching open PRs so fresh review feedback is surfaced promptly. Use when the user asks Codex to monitor a PR, watch CI, handle review comments, or keep an eye on failures and feedback on an open PR.