sql-pro

Optimizes SQL queries, designs database schemas, and analyzes execution plans across major database dialects.

Updated Mar 9, 2026
One-click install
npx skills add https://github.com/ArMaTeC/Redball --skill sql-pro-armatec
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-pro
Source: https://github.com/ArMaTeC/Redball/tree/main/.devin/skills/sql-pro
Command: npx skills add https://github.com/ArMaTeC/Redball --skill sql-pro-armatec

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Slow queries, missing indexes, and poorly designed schemas cause database performance bottlenecks that are hard to diagnose without deep SQL expertise. This Skill provides structured guidance for query optimization, schema design, and execution plan analysis. ## Core Features & Use Cases - Query Optimization: Analyze EXPLAIN/ANALYZE output, eliminate sequential scans, create covering indexes, and rewrite correlated subqueries into set-based operations. - Schema Design: Apply normalization (1NF-3NF), constraints, foreign keys, soft deletes, audit trails, and temporal data patterns. - Dialect Translation: Migrate queries between PostgreSQL, MySQL, SQL Server, and Oracle with correct syntax for pagination, UPSERT, JSON, and recursive CTEs. - Use Case: A developer has a reporting query taking 30 seconds. The Skill identifies the correlated subquery bottleneck, rewrites it as an aggregation join, and provides a covering index that brings execution under 100ms. ## Quick Start Ask the assistant to analyze why your SQL query is slow and optimize it with proper indexes and a rewritten execution plan.

Frequently Asked Questions about sql-pro

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize a slow SQL query?

Start by running EXPLAIN ANALYZE to see actual row counts versus estimates and identify sequential scans on large tables. Then add indexes on filtered and joined columns, rewrite correlated subqueries as aggregation joins, and filter rows early before joins.

How do I read a PostgreSQL EXPLAIN ANALYZE plan?

Look for Seq Scan nodes on large tables, which signal missing indexes, and compare actual rows against estimated rows to detect stale statistics. High buffer read counts versus shared hits indicate data coming from disk rather than cache.

What is the difference between ROW_NUMBER, RANK, and DENSE_RANK?

ROW_NUMBER assigns a unique sequential number to every row, while RANK gives tied rows the same rank and skips subsequent positions. DENSE_RANK also ties equal values but produces no gaps in the ranking sequence.

How do I write an UPSERT in PostgreSQL vs MySQL?

PostgreSQL uses INSERT ... ON CONFLICT (key) DO UPDATE SET with the EXCLUDED pseudo-table for new values. MySQL uses INSERT ... ON DUPLICATE KEY UPDATE, referencing new values via VALUES() or a row alias in version 8.0.19 and later.

When should I use a covering index?

Use a covering index when a frequent query touches only a small set of columns, so the database can answer entirely from the index without reading the table. In PostgreSQL, add extra columns with the INCLUDE clause to keep the index key narrow.

Why is my NOT IN subquery returning wrong results?

NOT IN returns no rows when the subquery produces any NULL value, because NULL comparisons evaluate to unknown. Rewrite it as NOT EXISTS with a correlated subquery, which handles NULLs correctly and often performs better.