sql-expert

Optimize and validate SQL queries across PostgreSQL, MySQL, and SQLite.

4|1|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/xcrrr/claude-skills --skill sql-expert-xcrrr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-expert
Source: https://github.com/xcrrr/claude-skills/tree/main/skills/coding/sql-expert
Command: npx skills add https://github.com/xcrrr/claude-skills --skill sql-expert-xcrrr

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

SQL Expert helps teams write correct, efficient SQL queries, identify performance bottlenecks, and design robust database access patterns, reducing bugs and run times.

Core Features & Use Cases

  • Write correct and readable SQL queries, including joins, subqueries, CTEs, and window functions.
  • Analyze and optimize query performance using EXPLAIN ANALYZE and indexing strategies.
  • Design normalized schemas and assess query plans for common anti-patterns to avoid N+1, data-type mismatches, and slow scans.
  • Provide guidance across PostgreSQL, MySQL, and SQLite dialects for portability and correctness.

Quick Start

Optimize this SQL query for performance and explain the changes.

Frequently Asked Questions about sql-expert

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

FAQPage Schema
How do I optimize SQL query performance using EXPLAIN ANALYZE?

Optimize SQL query performance by running EXPLAIN ANALYZE to read execution plans, identify slow sequential scans, and create appropriate indexes to reduce bottlenecks. It helps assess query plans to avoid common anti-patterns across PostgreSQL, MySQL, and SQLite.

What is the best way to avoid N+1 query problems and SQL anti-patterns?

Avoid N+1 query problems and SQL anti-patterns by designing normalized schemas and assessing query plans to detect data-type mismatches and slow scans. Writing correct queries with joins and CTEs ensures efficient database access patterns.

Does this SQL query optimization approach work with PostgreSQL, MySQL, and SQLite?

Yes, this SQL query optimization approach works with PostgreSQL, MySQL, and SQLite. It provides dialect-specific guidance for portability and correctness, ensuring queries are validated and optimized across different database environments.

When do I need to use CTEs and window functions in SQL queries?

Use CTEs and window functions in SQL queries when writing complex aggregations or hierarchical data transformations. They help structure correct and readable queries, replacing subqueries to improve maintainability and validate logic.

How do I fix slow sequential scans and create appropriate indexes?

Fix slow sequential scans by identifying bottlenecks in your execution plan and creating appropriate indexes on filtered columns. This performance tuning strategy targets the exact columns needed to accelerate data retrieval.

Why does my database query suffer from data-type mismatches and how can I fix it?

Database queries suffer from data-type mismatches when join columns or predicates have incompatible types, causing slow scans. Fix this by assessing query plans to ensure correct type alignment and avoid common SQL anti-patterns.