jpskill.com
🛠️ 開発・MCP コミュニティ

postgres-pro

PostgreSQLデータベースの管理、性能最適化、高可用性設定、バックアップ復旧、高度な機能実装を支援するSkill。

📜 元の英語説明(参考)

Use when user needs PostgreSQL database administration, performance optimization, high availability setup, backup/recovery, or advanced PostgreSQL feature implementation.

🇯🇵 日本人クリエイター向け解説

一言でいうと

PostgreSQLデータベースの管理、性能最適化、高可用性設定、バックアップ復旧、高度な機能実装を支援するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

PostgreSQL Professional

目的

データベース管理、パフォーマンス最適化、および高度な機能の実装に特化した、包括的な PostgreSQL の専門知識を提供します。高可用性と高度な拡張機能を備えた PostgreSQL デプロイメントで、最大限の信頼性、パフォーマンス、スケーラビリティを実現することに優れています。

使用場面

  • PostgreSQL 固有の機能が必要な場合 (JSONB、全文検索、PostGIS、pgvector)
  • ストリーミングレプリケーションまたは論理レプリケーションを設定する場合
  • PostgreSQL 拡張機能を実装する場合
  • PostgreSQL 固有の問題をトラブルシューティングする場合
  • PostgreSQL の構成を最適化する場合
  • パーティショニングと高可用性を実装する場合

クイックスタート

このスキルを呼び出すのは、以下の場合です。

  • PostgreSQL 固有の機能が必要な場合 (JSONB インデックス作成、全文検索、PostGIS、pgvector)
  • PostgreSQL のストリーミングレプリケーションまたは論理レプリケーションを設定する場合
  • PostgreSQL 拡張機能を実装する場合 (pg_trgm、PostGIS、timescaledb、pg_partman)
  • PostgreSQL 固有の問題をトラブルシューティングする場合 (autovacuum、bloat、WAL アーカイブ)
  • PostgreSQL の構成を最適化する場合 (shared_buffers、work_mem、vacuum 設定)
  • PostgreSQL のパーティショニングを実装する場合 (宣言的パーティショニング、制約除外)
  • PostgreSQL の高可用性を設定する場合 (Patroni、repmgr、pgpool-II)
  • GIN インデックスを使用した JSONB スキーマの設計とクエリ最適化を行う場合

以下の場合には呼び出さないでください。

  • 一般的な SQL クエリの記述 (ANSI SQL クエリには sql-pro を使用してください)
  • クロスプラットフォームのデータベース最適化 (一般的なチューニングには database-optimizer を使用してください)
  • MySQL または SQL Server 固有の機能 (プラットフォーム固有のスキルを使用してください)
  • データベース管理の基本 (ユーザー、権限 - database-administrator を使用してください)
  • PostgreSQL 固有の機能を使用しない単純なクエリ最適化
  • ORM クエリパターン (ORM の専門知識を持つ backend-developer を使用してください)

コア機能

PostgreSQL アーキテクチャ

  • プロセスアーキテクチャとメモリ構成
  • WAL メカニクスと MVCC 実装
  • ストレージレイアウトとバッファ管理
  • ロック管理とバックグラウンドワーカー

高度な機能

  • GIN インデックスによる JSONB 最適化
  • tsvector と GIN インデックスによる全文検索
  • PostGIS 空間クエリとインデックス作成
  • 時系列データ処理とパーティショニング
  • 外部データラッパーとクロスデータベースクエリ
  • 並列クエリと JIT コンパイル

パフォーマンスチューニング

  • 構成最適化 (メモリ、接続、チェックポイント)
  • クエリ最適化と実行計画分析
  • インデックス戦略とインデックス使用状況の監視
  • Vacuum チューニングと autovacuum 構成
  • コネクションプーリングと並列実行

レプリケーション戦略

  • ストリーミングレプリケーションと論理レプリケーション
  • 同期設定とカスケードレプリカ
  • 遅延レプリカとフェイルオーバー自動化
  • ロードバランシングと競合解決

バックアップとリカバリ

  • pg_dump 戦略と物理バックアップ
  • WAL アーカイブと PITR 設定
  • バックアップ検証とリカバリテスト
  • 自動化スクリプトと保持ポリシー

意思決定フレームワーク

JSONB インデックス戦略

JSONB Query Pattern Analysis
│
├─ Containment queries (@> operator)?
│   └─ Use GIN with jsonb_path_ops
│       CREATE INDEX idx ON table USING GIN (column jsonb_path_ops);
│       • 2-3x smaller than default GIN
│       • Faster for @> containment checks
│       • Does NOT support key existence (?)
│
├─ Key existence queries (? or ?| or ?& operators)?
│   └─ Use default GIN operator class
│       CREATE INDEX idx ON table USING GIN (column);
│       • Supports all JSONB operators
│       • Larger index size
│
├─ Specific path frequently queried?
│   └─ Use expression index
│       CREATE INDEX idx ON table ((column->>'key'));
│       • Most efficient for specific path
│       • B-tree allows range queries
│
└─ Full document search needed?
    └─ Combine GIN + expression indexes
        • GIN for flexible queries
        • Expression for hot paths

レプリケーション戦略の選択

要件 戦略 構成
読み取りスケーリング ストリーミング (非同期) 複数の読み取りレプリカ
データ損失ゼロ ストリーミング (同期) synchronous_commit = on
テーブルレベルレプリケーション 論理 CREATE PUBLICATION/SUBSCRIPTION
クロスバージョンアップグレード 論理 新しいバージョンへのレプリケーション
災害復旧 ストリーミング + WAL アーカイブ PITR 機能
遅延リカバリ 遅延レプリカ recovery_min_apply_delay

品質チェックリスト

パフォーマンス:

  • [ ] クエリパフォーマンス目標が達成されていること (OLTP <50ms、Analytics <2s)
  • [ ] すべての重要なクエリについて EXPLAIN ANALYZE がレビューされていること
  • [ ] JSONB、配列、全文検索クエリに GIN/GiST インデックスが使用されていること
  • [ ] 時系列データを持つ 10GB を超えるテーブルにパーティショニングが実装されていること
  • [ ] キャッシュヒット率が 95% を超えていること (shared_buffers + OS キャッシュ)
  • [ ] コネクションプーリングが実装されていること (PgBouncer またはアプリケーションプール)

構成:

  • [ ] shared_buffers = RAM の 25%
  • [ ] effective_cache_size = RAM の 75%
  • [ ] work_mem がワークロードに合わせて調整されていること (EXPLAIN で一時ファイルスピルがないこと)
  • [ ] Autovacuum が構成されていること (大規模テーブルの場合 scale_factor ≤0.05)
  • [ ] max_connections が適切であること (または PgBouncer を使用していること)
  • [ ] PITR のために WAL アーカイブが有効になっていること

レプリケーション (該当する場合):

  • [ ] レプリケーションスロットが作成されていること (WAL 削除を防止)
  • [ ] レプリケーションラグが 500ms 未満であること (P95)
  • [ ] pg_stat_replication が監視されていること (sync_state、replay_lag)
  • [ ] フェイルオーバーがテストされていること (レプリカをプライマリに昇格)
  • [ ] pg_hba.conf がレプリケーションアクセス用に構成されていること

拡張機能:

  • [ ] 必要な拡張機能がインストールされていること (pg_trgm、PostGIS、pgvector など)
  • [ ] 拡張機能のバージョンが PostgreSQL のバージョンと互換性があること
  • [ ] JSONB、tsvector、trigrams 用に GIN インデックスが作成されていること
  • [ ] 適切な言語辞書で全文検索が構成されていること

JSONB (使用する場合):

  • [ ] GIN インデックスが作成されていること (包含クエリには jsonb_path_ops)
  • [ ] 頻繁にクエリされるパスに式インデックスが作成されていること
  • [ ] アプリケーションで JSONB 検証が行われていること (jsonschema またはカスタム)
  • [ ] 深くネストされた JSONB がないこと (3 レベル以上 → 正規化を検討)

監視:

  • [ ] スロークエリログが構成されていること (log_min_d

(原文がここで切り詰められています)

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

PostgreSQL Professional

Purpose

Provides comprehensive PostgreSQL expertise specializing in database administration, performance optimization, and advanced feature implementation. Excels at achieving maximum reliability, performance, and scalability for PostgreSQL deployments with high availability and advanced extensions.

When to Use

  • PostgreSQL-specific features needed (JSONB, full-text search, PostGIS, pgvector)
  • Setting up streaming or logical replication
  • Implementing PostgreSQL extensions
  • Troubleshooting PostgreSQL-specific issues
  • Optimizing PostgreSQL configuration
  • Implementing partitioning and high availability

Quick Start

Invoke this skill when:

  • PostgreSQL-specific features needed (JSONB indexing, full-text search, PostGIS, pgvector)
  • Setting up streaming replication or logical replication for PostgreSQL
  • Implementing PostgreSQL extensions (pg_trgm, PostGIS, timescaledb, pg_partman)
  • Troubleshooting PostgreSQL-specific issues (autovacuum, bloat, WAL archiving)
  • Optimizing PostgreSQL configuration (shared_buffers, work_mem, vacuum settings)
  • Implementing PostgreSQL partitioning (declarative partitioning, constraint exclusion)
  • Setting up PostgreSQL high availability (Patroni, repmgr, pgpool-II)
  • Designing JSONB schema and query optimization with GIN indexes

Do NOT invoke when:

  • General SQL query writing (use sql-pro for ANSI SQL queries)
  • Cross-platform database optimization (use database-optimizer for general tuning)
  • MySQL or SQL Server specific features (use platform-specific skills)
  • Database administration basics (users, permissions - use database-administrator)
  • Simple query optimization without PostgreSQL-specific features
  • ORM query patterns (use backend-developer with ORM expertise)

Core Capabilities

PostgreSQL Architecture

  • Process architecture and memory configuration
  • WAL mechanics and MVCC implementation
  • Storage layout and buffer management
  • Lock management and background workers

Advanced Features

  • JSONB optimization with GIN indexes
  • Full-text search with tsvector and GIN indexes
  • PostGIS spatial queries and indexing
  • Time-series data handling and partitioning
  • Foreign data wrappers and cross-database queries
  • Parallel queries and JIT compilation

Performance Tuning

  • Configuration optimization (memory, connections, checkpoints)
  • Query optimization and execution plan analysis
  • Index strategies and index usage monitoring
  • Vacuum tuning and autovacuum configuration
  • Connection pooling and parallel execution

Replication Strategies

  • Streaming replication and logical replication
  • Synchronous setup and cascading replicas
  • Delayed replicas and failover automation
  • Load balancing and conflict resolution

Backup and Recovery

  • pg_dump strategies and physical backups
  • WAL archiving and PITR setup
  • Backup validation and recovery testing
  • Automation scripts and retention policies

Decision Framework

JSONB Index Strategy

JSONB Query Pattern Analysis
│
├─ Containment queries (@> operator)?
│   └─ Use GIN with jsonb_path_ops
│       CREATE INDEX idx ON table USING GIN (column jsonb_path_ops);
│       • 2-3x smaller than default GIN
│       • Faster for @> containment checks
│       • Does NOT support key existence (?)
│
├─ Key existence queries (? or ?| or ?& operators)?
│   └─ Use default GIN operator class
│       CREATE INDEX idx ON table USING GIN (column);
│       • Supports all JSONB operators
│       • Larger index size
│
├─ Specific path frequently queried?
│   └─ Use expression index
│       CREATE INDEX idx ON table ((column->>'key'));
│       • Most efficient for specific path
│       • B-tree allows range queries
│
└─ Full document search needed?
    └─ Combine GIN + expression indexes
        • GIN for flexible queries
        • Expression for hot paths

Replication Strategy Selection

Requirement Strategy Configuration
Read scaling Streaming (async) Multiple read replicas
Zero data loss Streaming (sync) synchronous_commit = on
Table-level replication Logical CREATE PUBLICATION/SUBSCRIPTION
Cross-version upgrade Logical Replicate to new version
Disaster recovery Streaming + WAL archive PITR capability
Delayed recovery Delayed replica recovery_min_apply_delay

Quality Checklist

Performance:

  • [ ] Query performance targets met (OLTP <50ms, Analytics <2s)
  • [ ] EXPLAIN ANALYZE reviewed for all critical queries
  • [ ] GIN/GiST indexes used for JSONB, array, full-text queries
  • [ ] Partitioning implemented for tables >10GB with time-series data
  • [ ] Cache hit ratio >95% (shared_buffers + OS cache)
  • [ ] Connection pooling implemented (PgBouncer or application pool)

Configuration:

  • [ ] shared_buffers = 25% of RAM
  • [ ] effective_cache_size = 75% of RAM
  • [ ] work_mem tuned for workload (no temp file spills in EXPLAIN)
  • [ ] Autovacuum configured (scale_factor ≤0.05 for large tables)
  • [ ] max_connections appropriate (or using PgBouncer)
  • [ ] WAL archiving enabled for PITR

Replication (if applicable):

  • [ ] Replication slots created (prevents WAL deletion)
  • [ ] Replication lag <500ms (P95)
  • [ ] pg_stat_replication monitored (sync_state, replay_lag)
  • [ ] Failover tested (promote replica to primary)
  • [ ] pg_hba.conf configured for replication access

Extensions:

  • [ ] Required extensions installed (pg_trgm, PostGIS, pgvector, etc.)
  • [ ] Extension versions compatible with PostgreSQL version
  • [ ] GIN indexes created for JSONB, tsvector, trigrams
  • [ ] Full-text search configured with proper language dictionaries

JSONB (if used):

  • [ ] GIN indexes created (jsonb_path_ops for containment queries)
  • [ ] Expression indexes for frequently queried paths
  • [ ] JSONB validation in application (jsonschema or custom)
  • [ ] No deeply nested JSONB (>3 levels → consider normalization)

Monitoring:

  • [ ] Slow query log configured (log_min_duration_statement = 200ms)
  • [ ] pg_stat_statements installed and monitored
  • [ ] Autovacuum progress monitored (pg_stat_progress_vacuum)
  • [ ] Table bloat monitored (<15% dead tuples)
  • [ ] Replication lag alerts configured (<1s threshold)

Additional Resources