sql-pro

Write complex SQL queries and optimize execution plans for PostgreSQL, MySQL, and SQL Server.

1|1|Updated Aug 5, 2025
One-click install
npx skills add https://github.com/slantview/claude --skill sql-pro-slantview
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-pro
Source: https://github.com/slantview/claude/tree/main/skills/sql-pro
Command: npx skills add https://github.com/slantview/claude --skill sql-pro-slantview

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill tackles the complexities of writing efficient SQL queries, optimizing database performance, and designing robust database schemas.

Core Features & Use Cases

  • Complex Query Writing: Generates advanced SQL using CTEs, window functions, and stored procedures.
  • Query Optimization: Analyzes and improves the performance of existing SQL queries.
  • Database Design: Assists in creating normalized schemas with appropriate indexes and constraints.
  • Use Case: Optimize a slow-running SELECT statement that joins multiple large tables by analyzing its execution plan and adding necessary indexes.

Quick Start

Use the sql-pro skill to write a PostgreSQL query that calculates the rolling 7-day average of daily sales from the 'sales_data' table.

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 joining multiple large tables?

Optimize slow SQL queries by analyzing execution plans with EXPLAIN ANALYZE to identify bottlenecks, then apply index strategies and rewrite joins. This reduces scan times and improves performance across large tables.

How do I write a SQL query to calculate a rolling 7-day average using window functions?

Calculate a rolling 7-day average using SQL window functions by defining a window frame of the preceding seven rows ordered by date. This mechanism processes related rows together to compute running aggregations efficiently without self-joins.

Does this SQL optimization approach work with MySQL and SQL Server or just PostgreSQL?

This approach supports query optimization and schema design across PostgreSQL, MySQL, and SQL Server dialects. It adapts execution plan analysis and index strategies to the specific SQL dialect you are using.

What is the best way to design a normalized database schema with appropriate indexes?

The best way to design normalized database schemas is to organize data to reduce redundancy, define appropriate data types, and apply constraints. Adding targeted indexes based on query patterns ensures data integrity and fast retrieval.

When should I use CTEs instead of subqueries in complex SQL queries?

Use CTEs in complex SQL queries to improve readability and structure when reusing logic or chaining multiple operations. CTEs act as temporary result sets that simplify maintenance compared to deeply nested subqueries.

Why does my SQL query ignore the index I created on a large table?

SQL queries ignore indexes when the execution plan determines a full table scan is cheaper due to data distribution or data type mismatches. Analyzing the plan with EXPLAIN ANALYZE reveals why the index is not being used.