本文へ移動
cccskills
無料GitHub で公開

postgres-best-practices

PostgreSQL best practices for database design, query optimization, and performance tuning

インストール方法を見る

含まれるファイル(1)

  • SKILL.md1.8 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

PostgreSQL Best Practices

Query Optimization

EXPLAIN ANALYZE (CRITICAL)

  • Use EXPLAIN ANALYZE to understand query plans
  • Identify slow operations: Seq Scan, Nested Loop
  • Check row estimates vs actual rows
  • Monitor buffers: shared hit vs read

Indexing (CRITICAL)

  • B-tree: default, most use cases
  • GIN: JSONB, arrays, full-text search
  • GiST: geometry, range types
  • BRIN: large sequential tables (time-series)
  • Partial indexes: filtered queries
  • Covering indexes (INCLUDE): avoid heap fetches

Index Maintenance

  • Create indexes concurrently: CREATE INDEX CONCURRENTLY
  • Monitor usage: pg_stat_user_indexes
  • Remove unused indexes
  • Reindex bloated indexes

Table Design

Partitioning (HIGH)

  • Range partitioning: time-series data
  • List partitioning: categorical data
  • Hash partitioning: even distribution
  • Declarative partitioning (PG 10+)

Data Types

  • Use appropriate types (int vs bigint, varchar vs text)
  • JSONB for semi-structured data
  • Arrays for multi-value columns
  • UUIDs for distributed IDs

Performance Tuning

Vacuum and Autovacuum

  • Autovacuum: default enabled
  • Monitor bloat: pg_stat_user_tables
  • Tune autovacuum thresholds
  • Manual VACUUM for large updates

Connection Pooling

  • Use pgBouncer or PgPool
  • Transaction pooling for short transactions
  • Session pooling for long transactions
  • Max connections: tune based on workload

Configuration

  • shared_buffers: 25% of RAM
  • work_mem: per operation, tune carefully
  • effective_cache_size: 50-75% of RAM
  • random_page_cost: 1.1 for SSD

References

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Pre-action boundary checking — validates agent tool calls against declared capabilities and task contracts

日本語の概要は準備中です。原文の説明を表示しています。

baekenough/second-brain152026年10月8日 更新

Auto-detect project context and optimize harness — deactivate unused agents/skills, suggest missing experts, generate project profile

日本語の概要は準備中です。原文の説明を表示しています。

baekenough/second-brain152026年10月8日 更新

Adversarial code review using attacker mindset — trust boundary, attack surface, business logic, and defense evaluation

日本語の概要は準備中です。原文の説明を表示しています。

baekenough/second-brain152026年10月8日 更新

Apache Airflow best practices for DAG authoring, testing, and production deployment

日本語の概要は準備中です。原文の説明を表示しています。

baekenough/second-brain152026年10月8日 更新

Alembic migration patterns for naming conventions, safety checks, expand-contract, env.py configuration, and CI integration

日本語の概要は準備中です。原文の説明を表示しています。

baekenough/second-brain152026年10月8日 更新

Pre-routing ambiguity analysis — scores request clarity and asks clarifying questions when needed (inspired by ouroboros)

日本語の概要は準備中です。原文の説明を表示しています。

baekenough/second-brain152026年10月8日 更新

baekenough のスキルをすべて見る

このスキルの問題を報告する