sql-patterns

Provide SQL query patterns and best practices for PostgreSQL, MySQL, and SQLite.

Updated Dec 4, 2025
One-click install
npx skills add https://github.com/eous/dotclaude --skill sql-patterns-eous
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-patterns
Source: https://github.com/eous/dotclaude/tree/main/skills/sql-patterns
Command: npx skills add https://github.com/eous/dotclaude --skill sql-patterns-eous

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps developers write efficient and correct SQL by providing proven patterns for querying, optimization, and schema design across PostgreSQL, MySQL, and SQLite.

Core Features & Use Cases

  • SELECT best practices: avoid SELECT * and use explicit columns.
  • JOINs and aggregations: use proper join types, avoid N+1 queries, and leverage GROUP BY and window functions.
  • Indexing and schema design: guidance on indexing strategies and normalization considerations.

Quick Start

Provide an optimized rewrite of a given SQL query and explain the indexing and join choices behind the optimization.

Frequently Asked Questions about sql-patterns

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

FAQPage Schema
How do I optimize slow SQL queries using indexing and joins?

Optimize slow SQL queries by applying proper indexing strategies, selecting explicit columns instead of SELECT *, and choosing correct join types to avoid N+1 issues. Rewriting queries with modern SQL features like CTEs and window functions also improves data retrieval performance.

What is the best way to write SQL aggregations with GROUP BY and window functions?

The best way to write SQL aggregations is leveraging GROUP BY for grouped summaries and window functions for row-level calculations across partitions. This approach ensures correct data retrieval while maintaining query efficiency across PostgreSQL, MySQL, and SQLite.

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

Yes, the SQL query optimization patterns apply to PostgreSQL, MySQL, and SQLite. The guidance covers indexing strategies, schema design, and modern SQL features tailored for application code and analytics work across these specific database platforms.

When do I need to use CTEs in SQL query performance tuning?

Use CTEs in SQL query performance tuning when breaking down complex SELECT statements into readable, modular blocks. CTEs help structure intricate data retrieval logic and aggregations, making query optimization and maintenance significantly easier.

How to avoid N+1 queries when using JOINs in database schema design?

Avoid N+1 queries by using proper JOIN types to fetch related data in a single database round-trip. Effective schema design and indexing strategies ensure these JOIN operations perform efficiently without repeated data retrieval calls.