database-optimizer
하는 일
데이터베이스 성능을 측정하고 개선하는 과정을 AI 에이전트가 안내합니다. 느린 쿼리나 과도한 부하가 있는 개발자와 데이터베이스 관리자를 위한 스킬입니다.
사용하는 경우
- ✓데이터베이스 쿼리가 느려서 이유를 알아내야 할 때.
- ✓인덱스를 설계하거나 데이터베이스 설정을 튜닝하고 싶을 때.
- ✓PostgreSQL이나 MySQL에서 락 경합이나 교착 상태가 보일 때.
스킬 링크
https://github.com/Jeffallan/claude-skills/blob/main/skills/database-optimizer/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“이 보고서 쿼리가 PostgreSQL에서 40초 걸립니다. 이유를 찾아 빠르게 해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 기준선을 기록하고, 실행 계획을 실행해 병목을 찾습니다. 변경은 한 번에 하나씩 적용하고, 다음으로 넘어가기 전에 각 변경을 측정합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Database Optimizer
Senior database optimizer with expertise in performance tuning, query optimization, and scalability across multiple database systems.
When to Use This Skill
- Analyzing slow queries and execution plans
- Designing optimal index strategies
- Tuning database configuration parameters
- Optimizing schema design and partitioning
- Reducing lock contention and deadlocks
- Improving cache hit rates and memory usage
Core Workflow
- Analyze Performance — Capture baseline metrics and run
EXPLAIN ANALYZEbefore any changes - Identify Bottlenecks — Find inefficient queries, missing indexes, config issues
- Design Solutions — Create index strategies, query rewrites, schema improvements
- Implement Changes — Apply optimizations incrementally with monitoring; validate each change before proceeding to the next
- Validate Results — Re-run
EXPLAIN ANALYZE, compare costs, measure wall-clock improvement, document changes
⚠️ Always test changes in non-production first. Revert immediately if write performance degrades or replication lag increases.
Reference Guide
Load detailed guidance based on context:
| Topic | Reference | Load When |
|---|---|---|
| Query Optimization | references/query-optimization.md |
Analyzing slow queries, execution plans |
| Index Strategies | references/index-strategies.md |
Designing indexes, covering indexes |
| PostgreSQL Tuning | references/postgresql-tuning.md |
PostgreSQL-specific optimizations |
| MySQL Tuning | references/mysql-tuning.md |
MySQL-specific optimizations |
| Monitoring & Analysis | references/monitoring-analysis.md |
Performance metrics, diagnostics |
Common Operations & Examples
Identify Top Slow Queries (PostgreSQL)
-- Requires pg_stat_statements extension
SELECT query,
calls,
round(total_exec_time::numeric, 2) AS total_ms,
round(mean_exec_time::numeric, 2) AS mean_ms,
round(stddev_exec_time::numeric, 2) AS stddev_ms,
rows
FROM pg_stat_statements
ORDER BY mean_exec_time DESC
LIMIT 20;
Capture an Execution Plan
-- Use BUFFERS to expose cache hit vs. disk read ratio
EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
SELECT o.id, c.name
FROM orders o
JOIN customers c ON c.id = o.customer_id
WHERE o.status = 'pending'
AND o.created_at > now() - interval '7 days';
Reading EXPLAIN Output — Key Patterns to Find
| Pattern | Symptom | Typical Remedy |
|---|---|---|
Seq Scan on large table |
High row estimate, no filter selectivity | Add B-tree index on filter column |
Nested Loop with large outer set |
Exponential row growth in inner loop | Consider Hash Join; index inner join key |
cost=... rows=1 but actual rows=50000 |
Stale statistics | Run ANALYZE <table>; |
Buffers: hit=10 read=90000 |
Low buffer cache hit rate | Increase shared_buffers; add covering index |
Sort Method: external merge |
Sort spilling to disk | Increase work_mem for the session |
Create a Covering Index
-- Covers the filter AND the projected columns, eliminating a heap fetch
CREATE INDEX CONCURRENTLY idx_orders_status_created_covering
ON orders (status, created_at)
INCLUDE (customer_id, total_amount);
Validate Improvement
-- Before optimization: save plan & timing
EXPLAIN (ANALYZE, BUFFERS) <query>; -- note "Execution Time: X ms"
-- After optimization: compare
EXPLAIN (ANALYZE, BUFFERS) <query>; -- target meaningful reduction in cost & time
-- Confirm index is actually used
SELECT indexname, idx_scan, idx_tup_read, idx_tup_fetch
FROM pg_stat_user_indexes
WHERE relname = 'orders';
MySQL: Find Slow Queries
-- Inspect slow query log candidates
SELECT * FROM performance_schema.events_statements_summary_by_digest
ORDER BY SUM_TIMER_WAIT DESC
LIMIT 20;
-- Execution plan
EXPLAIN FORMAT=JSON
SELECT * FROM orders WHERE status = 'pending' AND created_at > NOW() - INTERVAL 7 DAY;
Constraints
MUST DO
- Capture
EXPLAIN (ANALYZE, BUFFERS)output before optimizing — this is the baseline - Measure performance before and after every change
- Create indexes with
CONCURRENTLY(PostgreSQL) to avoid table locks - Test in non-production; roll back if write performance or replication lag worsens
- Document all optimization decisions with before/after metrics
- Run
ANALYZEafter bulk data changes to refresh statistics
MUST NOT DO
자주 묻는 질문
실시간 데이터로 변경을 테스트해도 되나요?
아닙니다. 스킬은 먼저 운영 환경이 아닌 곳에서 테스트하고, 쓰기가 느려지면 되돌리라고 설명합니다.
어떤 데이터베이스를 다루나요?
PostgreSQL과 MySQL을 다룹니다.
무엇을 측정하나요?
각 변경 전후의 실행 계획 비용과 실제 실행 시간을 비교합니다.
상세 정보
작성자의 원본 설명
Optimizes database queries and improves performance across PostgreSQL and MySQL systems. Use when investigating slow queries, analyzing execution plans, or optimizing database performance. Invoke for index design, query rewrites, configuration tuning, partitioning strategies, lock contention resolution.
repo: Jeffallan/claude-skills
인기도
- GitHub 스타
- 12k
- 순위
- #11415
- 라이선스
- MIT
- 업데이트
- 2026. 10. 30.
댓글
- …
이 저장소의 다른 스킬
angular-architect
12k에이전트가 독립형 컴포넌트, 지연 로딩 라우팅, NgRx 상태 관리, RxJS 패턴, 성능 최적화를 갖춘 Angular 17 이상 앱을 만들도록 돕습니다.
api-designer
12k에이전트가 REST 또는 GraphQL API를 설계하고 OpenAPI 3.1 명세를 작성하도록 돕습니다. 리소스, 페이지네이션, 오류 형식, 버전 관리 규칙을 포함합니다.
architecture-designer
12k에이전트가 시스템 아키텍처를 설계하고, 패턴과 기술을 비교하며, 각 선택의 이유를 설명하는 ADR을 작성하도록 돕습니다.
atlassian-mcp
12kMCP를 통해 Jira 이슈와 Confluence 페이지를 검색하고 수정하도록 에이전트를 돕습니다. JQL과 CQL 검색, 스프린트, 문서 동기화를 포함합니다.
비슷한 스킬
discrawl
394k에이전트가 저장된 로컬 Discord 메시지 보관본을 검색하고 요약하며, 최신 상태를 확인하고 다이렉트 메시지를 읽도록 돕습니다.
clickhouse-io
280k에이전트가 ClickHouse 데이터베이스의 쿼리와 스키마를 최적화하도록 돕습니다. 고성능 분석 작업의 모범 사례를 적용합니다. 분석 쿼리가 느릴 때 씁니다.
scientific-db-pubmed-database
280k생의학 분야의 과학 논문을 에이전트가 검색하도록 돕습니다. 특정 의학 정보가 필요한 연구에 유용합니다.