database-optimizer
Use when DB slowness is server-side, not query text. Triggers on: "락 경합", "VACUUM 밀림", "shared_buffers 튜닝", "파티셔닝 설계", "lock contention", "stale statistics", "InnoDB buffer pool". Not for SQL rewrites or pool sizing.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- database-optimizer
- license
- MIT
- metadata
- { "role": "specialist", "scope": "optimization", "domain": "infrastructure", "version": "1.1.0", "triggers": "server-side database tuning, vacuum lag, lock waits, buffer pool sizing, partitioning, EXPLAIN ANALYZE reading", "output-format": "findings-with-config-and-sql", "related-skills": "sql-pro, connection-pool-tuner, sre-engineer" }
- scenarios
- [ "Our database queries are slow and we're hitting performance bottlenecks", "Help me optimize this SQL query that takes 30 seconds on a 10M row table", "Need to scale our PostgreSQL database — it can't handle current load", "DB 쿼리가 너무 느려서 서비스 응답시간이 30초야", "PostgreSQL 성능 최적화 방법을 알려줘" ]
- description
- Use when DB slowness is server-side, not query text. Triggers on: "락 경합", "VACUUM 밀림", "shared_buffers 튜닝", "파티셔닝 설계", "lock contention", "stale statistics", "InnoDB buffer pool". Not for SQL rewrites or pool sizing.
- compatibility
- { "optional": [ "sequential-thinking" ], "recommended": [ "think-tool" ], "remote_mcp_note": "think-tool이 있으면 병목 원인 분석과 최적화 우선순위 결정을 더 체계적으로 수행합니다. sequential-thinking은 베이스라인 캡처 → 변경 → 검증 순서를 강제합니다. Claude 설정 → MCP Servers에서 remote SSE 엔드포인트를 추가하세요." }
02 资源文件 7
- 参考文档references/index-design-patterns.md3.8 KB
- 参考文档references/monitoring-mysql.md2.2 KB
- 参考文档references/monitoring-postgresql.md3.3 KB
- 参考文档references/mysql-memory-io.md4.2 KB
- 参考文档references/postgresql-memory-wal.md3.4 KB
- 参考文档references/postgresql-vacuum-locking.md5.0 KB
- 参考文档references/query-optimization.md4.1 KB
03 SKILL.md 正文
Standing Mandates
- NEVER change anything before a baseline is recorded (
EXPLAIN (ANALYZE, BUFFERS), latency, cache hit rate), and never make two changes in one round. Two changes at once make the net number unattributable. No baseline supplied is[확인 필요: baseline]and the tuning stops there. - NEVER run
ALTER SYSTEMor editmy.cnfon a managed database (RDS, Cloud SQL, Aurora); use the parameter group. Deployment type unknown is[확인 필요: deployment]. - Do NOT add an index that duplicates another's leading columns or serves no measured query; each index taxes every write.
- A gain not shown by a before/after measurement is
unverified, never "should be faster". - Goal: each change has a baseline number, an after number, and a keep or revert; stop at the target or after 3 rounds with no gain, reporting what remains. The closing tally recounts to the change lines.
Database Optimizer
Finds the server-side cause of database slowness (memory, VACUUM, locks, statistics, partitioning) and changes it one measured step at a time.
Not for rewriting the query text (develop:sql-pro) or pool sizing (develop:connection-pool-tuner).
Process
- Triage. Engine and version, deployment type (self-managed or cloud-managed), direct access or not.
- Baseline.
EXPLAIN (ANALYZE, BUFFERS), latency, buffer hit rate. - Bottleneck. Read the plan and server stats: costly nodes, absent indexes, stale statistics, lock waits, VACUUM lag.
- One change. Index, parameter, or partition; PostgreSQL indexes
CONCURRENTLY; rehearse outside production. - Measure. Re-run the baseline; keep or revert. Revert if writes slow or replicas fall behind. Then the next change. Before sending, recount the tally against the change lines; fix the header if they differ.
| Plan signal | Suggests | Usual first move |
|---|---|---|
Seq Scan over a big table |
Few rows kept, nothing indexed | B-tree index on the filtered column |
Nested Loop, large outer side |
Inner re-probed per outer row | Index the inner join key, or let a hash join win |
Estimated rows=1, actual 50000 |
Statistics out of date | ANALYZE the table |
Buffers: hit=40 read=120000 |
Pages mostly from disk | Grow shared_buffers, or add a covering index |
Sort Method: external merge Disk |
Sort overflowed memory | Raise work_mem for that session or role |
| Area | File | Read when |
|---|---|---|
| Plans and query shape | references/query-optimization.md |
Reading EXPLAIN output, slow statements |
| Index design | references/index-design-patterns.md |
B-tree, covering, partial, expression |
| PostgreSQL memory and WAL | references/postgresql-memory-wal.md |
shared_buffers, work_mem, WAL |
| PostgreSQL VACUUM and locking | references/postgresql-vacuum-locking.md |
VACUUM, locks, SKIP LOCKED, advisory locks, lock order |
| MySQL memory and I/O | references/mysql-memory-io.md |
InnoDB memory, I/O |
| Monitoring | references/monitoring-postgresql.md, references/monitoring-mysql.md |
pg_stat_statements, locks; performance schema, InnoDB status |
Output Template
## DB tuning — <system> (<engine> <version>, <self-managed | managed>)
Baseline: <latency, plan cost, hit rate>
Change <n>: <what> → after <numbers> → keep | revert
Monitoring to keep: <metrics>
<n> changes · <k> kept · <r> reverted · <u> unverified
What Claude Does / What You Do
| Claude | You |
|---|---|
| Reads EXPLAIN, names the bottleneck, proposes one change | Provide the actual EXPLAIN output and engine/deployment facts |
| Writes the parameter or index change and the validation queries | Apply via parameter group or ALTER SYSTEM; run CREATE INDEX CONCURRENTLY |
| Flags managed-platform constraints | Confirm the gain on production-sized data |
Related Skills
develop:sql-pro— rewrite slow queries once the server is configureddevelop:connection-pool-tuner— pool sizing after server config is validateddevelop:sre-engineer— monitoring and alerting on database golden signals
04 同仓库更多 Skills
diagram
Use when something must be drawn as a checked figure, not Mermaid: page layout, B-tree, lock timeline, ER, benchmark chart, architecture, sequence. SVG + PNG. Triggers: "도식화해줘", "그림으로 그려줘", "책에 넣을 그림", "시퀀스 다이어그램", "draw this as a figure".
test-master
Use when writing, improving, or auditing tests, or writing case specs with expected results from a spec. Triggers: "테스트 작성", "테스트 케이스 작성", "test case writing", "단위 테스트", "커버리지 분석", "test plan", "defect report".
sre-engineer
Use when setting up production reliability practices. Triggers on: "SLO 정하고 싶어", "에러 버짓", "알람 피로", "반복 작업(toil) 줄이기", "golden signals dashboard", "burn-rate alert". Not for active incidents or chaos tests.
sql-pro
Use when someone needs help writing or rewriting SQL — authoring complex joins, CTEs, window functions, or recursive queries — or designing a schema from scratch, normalizing an existing one, or migrating queries between database dialects.
spring-boot-engineer
Use when building or extending a Spring Boot 3.x Java backend — REST, Spring Security, JPA, WebFlux, Actuator. Triggers on: "Spring Boot API", "스프링 시큐리티 설정", "JPA 연동". Not for service decomposition or query tuning.
spec-driven-development
Use when a feature should be specified before it is coded — stories, acceptance criteria, tasks, a per-criterion check. Triggers: "스펙 먼저", "명세부터 쓰고 구현", "수용 기준 먼저", "spec first", "spec-driven development".