sql-optimization-patterns
SQLクエリ最適化、インデックス戦略、EXPLAIN分析をマスターし、データベースパフォーマンスを劇的に向上させ、遅いクエリを排除。遅いクエリのデバッグ、データベーススキーマの設計、アプリケーションパフォーマンスの最適化時に使用。
Security Assessment
About sql-optimization-patterns
The SQL Optimization Patterns skill provides a structured approach to improving database performance by analyzing and optimizing slow queries. It focuses on understanding query execution plans, implementing effective indexing strategies, and applying best practices for SQL query design. This skill is essential for developers and database administrators who want to reduce execution times, lower database load, and enhance the efficiency of their applications. By leveraging these patterns, users can identify bottlenecks and transform sluggish queries into highly performant operations.
Key features include the ability to interpret EXPLAIN outputs for PostgreSQL, recognizing metrics such as sequential scans, index scans, nested loops, hash joins, and merge joins to assess query performance. It also covers multiple types of indexes including B-Tree, Hash, GIN, GiST, BRIN, as well as specialized indexes like partial, expression-based, and covering indexes. Additionally, it provides guidance on query optimization patterns such as avoiding SELECT *, using WHERE clauses efficiently, and optimizing JOIN operations. This skill also addresses the N+1 query problem and demonstrates solutions using JOINs or batch queries to minimize database round trips.
This skill is particularly useful for developers, database administrators, and performance engineers who are working with PostgreSQL databases and need to improve application response times, design high-performance database schemas, or scale systems efficiently as data volumes grow. It is applicable when debugging slow queries, analyzing EXPLAIN plans, implementing effective indexing, and solving common performance issues in applications that interact heavily with databases.
FAQ
When should I use this skill?
Use this skill when debugging slow SQL queries, designing high-performance database schemas, optimizing application response times, or analyzing EXPLAIN query plans for efficiency.
Which databases are supported?
This skill focuses primarily on PostgreSQL, utilizing its EXPLAIN outputs and indexing features for optimization.
Does this skill handle N+1 query problems?
Yes, it provides strategies to eliminate N+1 queries using JOIN operations or batch queries to reduce unnecessary database round trips.
Are there limitations on the types of queries that can be optimized?
The skill covers common query patterns and indexing strategies, but highly specialized queries or non-PostgreSQL databases may require additional considerations.
Do I need prior SQL knowledge to use this skill?
Basic familiarity with SQL and relational databases is recommended to effectively interpret query plans, create indexes, and apply optimization patterns.
Install sql-optimization-patterns
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
amurata/cc-tools