Sql Query Optimizer
Expert-level SQL tuning and performance auditing for PostgreSQL, MySQL, SQLite, and SQL Server.
- Reduce query latency by identifying and fixing non-sargable WHERE clauses.
- Convert slow OFFSET-based pagination to high-performance keyset pagination.
- Eliminate N+1 query patterns in application code through efficient JOINs.
$14.99
· or 75 creditsSecure checkout via Stripe
Included in download
- Convert slow OFFSET-based pagination to high-performance keyset pagination.
- Eliminate N+1 query patterns in application code through efficient JOINs.
- terminal automation included
- Ready for Cursor
Sample input
This analytical query on our 500k row orders table is taking 30 seconds. Can you optimize it and suggest any missing indexes? SELECT * FROM orders WHERE EXTRACT(YEAR FROM created_at) = 2024;
Sample output
I've rewritten the query to use a sargable range scan: `SELECT id, customer_id, total FROM orders WHERE created_at >= '2024-01-01' AND created_at < '2025-01-01';` Recommendation: Create an index on `created_at`. This changes a full Table Scan (500k rows) to an Index Range Scan (~12k rows).
Sql Query Optimizer
Expert-level SQL tuning and performance auditing for PostgreSQL, MySQL, SQLite, and SQL Server.
$14.99
· or 75 creditsSecure checkout via Stripe
Included in download
- Convert slow OFFSET-based pagination to high-performance keyset pagination.
- Eliminate N+1 query patterns in application code through efficient JOINs.
- terminal automation included
- Ready for Cursor
- Instant install
Sample input
This analytical query on our 500k row orders table is taking 30 seconds. Can you optimize it and suggest any missing indexes? SELECT * FROM orders WHERE EXTRACT(YEAR FROM created_at) = 2024;
Sample output
I've rewritten the query to use a sargable range scan: `SELECT id, customer_id, total FROM orders WHERE created_at >= '2024-01-01' AND created_at < '2025-01-01';` Recommendation: Create an index on `created_at`. This changes a full Table Scan (500k rows) to an Index Range Scan (~12k rows).
About This Skill
What it does
This skill transforms your AI agent into a senior database performance engineer. It provides a systematic methodology for diagnosing slow SQL queries, interpreting complex execution plans, and rewriting code for maximum efficiency across PostgreSQL, MySQL, SQLite, and SQL Server.
Why use this skill
Standard LLMs often suggest generic SQL adjustments that might not actually trigger index usage or could even degrade write performance. This skill implements a developer-centric workflow: it demands EXPLAIN plans, identifies specific anti-patterns like non-sargable predicates and N+1 loops, and provides concrete before/after benchmarks. It ensures your agent understands dialect-specific nuances, such as how MySQL handles implicit type casts versus PostgreSQL's CTE materialization strategies.
Key Features
- Execution Plan Analysis: Deep interpretation of EXPLAIN ANALYZE and SCAN TABLE outputs.
- Index Strategy: Recommendations for composite and covering indexes based on read-to-write ratios.
- Query Refactoring: Converting slow correlated subqueries into efficient joins and implementing keyset pagination.
- Anti-Pattern Detection: Automatic flagging of 'SELECT *', wildcard prefixes, and improper NULL handling.
The Output
The agent delivers a structured performance report including the optimized SQL, the specific reasoning for each change, detailed index recommendations, and an estimated performance delta (e.g., Seq Scan to Index Scan transition).
Use Cases
- Reduce query latency by identifying and fixing non-sargable WHERE clauses.
- Convert slow OFFSET-based pagination to high-performance keyset pagination.
- Eliminate N+1 query patterns in application code through efficient JOINs.
- Interpret EXPLAIN plans to fix full table scans in production environments.
Known Limitations
- Does not support NoSQL or non-relational DBs. - Cannot execute live queries: requires manual EXPLAIN input. - Advanced vendor-specific hints may vary by version.
How to Install
mkdir -p ~/.claude/skills && curl -sL https://www.agensi.io/api/install/sql-query-optimizer -o /tmp/sql-query-optimizer.zip && unzip -o /tmp/sql-query-optimizer.zip -d ~/.claude/skills && rm /tmp/sql-query-optimizer.zipFree skills install directly. Paid skills require purchase - use the download button above after buying.
Reviews
No reviews yet - be the first to share your experience.
Only users who have downloaded or purchased this skill can leave a review.
Early access skill
Be the first to review this skill.
Only users who have downloaded or purchased this skill can leave a review.
Security Scanned
Passed automated security review
Permissions
Allowed Hosts
File Scopes
Compatible with SKILL.md-compatible agents including Claude Code, Cursor, and Aider.