sql-pro

Optimize SQL queries, design schemas, and troubleshoot performance issues.

Updated Oct 21, 2022
One-click install
npx skills add https://github.com/Chengxufeng1994/dotfiles --skill sql-pro-chengxufeng1994
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-pro
Source: https://github.com/Chengxufeng1994/dotfiles/tree/main/claude/skills/sql-pro
Command: npx skills add https://github.com/Chengxufeng1994/dotfiles --skill sql-pro-chengxufeng1994

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps users write faster, more efficient SQL queries and design robust database schemas, preventing performance bottlenecks and ensuring data integrity.

Core Features & Use Cases

  • Query Optimization: Analyzes and rewrites slow SQL queries, identifies missing indexes, and interprets execution plans.
  • Schema Design: Provides guidance on normalization, key constraints, and best practices for database structure.
  • Use Case: A user has a complex aggregation query that is taking minutes to run. They can use this Skill to analyze the query, suggest indexing strategies, and rewrite it for sub-second performance.

Quick Start

Use the sql-pro skill to optimize the following SQL query: SELECT * FROM orders WHERE order_date > '2023-01-01';

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 taking minutes to run?

To optimize a slow SQL query, you must analyze its execution plan using EXPLAIN/ANALYZE, identify missing indexes, and rewrite complex aggregations or joins for sub-second performance. This process involves interpreting query plans and applying indexing strategies.

What is the best way to design a database schema for data integrity?

Designing a robust database schema requires applying normalization principles, defining key constraints, and following best practices for database structure. This approach prevents performance bottlenecks and ensures strict data integrity across your tables.

How do I interpret an EXPLAIN/ANALYZE execution plan to troubleshoot database performance?

Interpreting an EXPLAIN/ANALYZE execution plan involves analyzing the query execution sequence to identify bottlenecks like full table scans or missing covering indexes. This troubleshooting method reveals why a query is slow and guides query rewrites.

Can I migrate complex SQL queries between PostgreSQL, MySQL, SQL Server, and Oracle dialects?

You can migrate complex SQL queries between PostgreSQL, MySQL, SQL Server, and Oracle dialects by translating specific syntax for window functions, CTEs, and recursive queries. This ensures functional continuity across different database platforms.

When should I use covering indexes or CTEs for SQL performance tuning?

You should use covering indexes during SQL performance tuning when a query's selected columns can be entirely satisfied by the index structure, and use CTEs to simplify complex multi-step aggregations or recursive queries for better readability and execution.

Does this approach work for complex aggregations and recursive queries?

This approach effectively handles complex aggregations and recursive queries by analyzing the execution flow, suggesting appropriate indexing strategies, and rewriting the SQL statements to achieve significant performance improvements and faster execution times.