PostgreSQL Database
Paste the following prompt into your AI chat to install this skill:
Please install @user_f12a44b7/self-dev-pg according to https://skillhub.cn/install/skillhub.md.
About this skill
Problem
PostgreSQL performance issues often come from index choices, connection behavior, type semantics, and operational details rather than SQL syntax. WHERE active = true may benefit from a partial index, WHERE lower(email) = ... needs an expression index, and joins on foreign key columns can miss indexes. Another trap is write overhead: unused indexes increase maintenance costs, low-cardinality indexes may be ignored, and LIKE '%suffix' usually cannot use a plain B-tree.
How It Works
The skill organizes PostgreSQL practice as a checklist:
- Indexes: partial indexes, expression indexes, covering indexes, foreign key columns, and composite index order;
- Queries and concurrency: SELECT FOR UPDATE SKIP LOCKED, pg_advisory_lock, IS NOT DISTINCT FROM, and DISTINCT ON;
- Connections and resources: PgBouncer, statement_timeout, idle_in_transaction_session_timeout, and max_connections tuning;
- Data and operations: IDENTITY, TIMESTAMPTZ, NUMERIC, TEXT, autovacuum, VACUUM ANALYZE, pg_repack, and transaction isolation levels.
Boundaries
It is useful for debugging slow queries, reviewing schema choices, and checking PostgreSQL usage, but it is not a database provisioning tool. In production, decisions should still be validated with EXPLAIN (ANALYZE, BUFFERS), statistics, data volume, and business constraints, especially SERIALIZABLE 40001 retries, full-text search language settings, and lock impact from long transactions.
Use Cases
- Diagnose slow queries with `EXPLAIN (ANALYZE, BUFFERS)` to detect missing indexes, heap fetches, and stale statistics.
- Design login or order tables using `IDENTITY`, `TIMESTAMPTZ`, `NUMERIC`, and `TEXT` where constraints matter.
- Build job queues using `SELECT FOR UPDATE SKIP LOCKED` and `pg_advisory_lock` for coordinated concurrent access.
- Maintain write-heavy tables by reviewing unused indexes, low-cardinality indexes, and autovacuum lag.
Best For
- Backend engineers troubleshooting PostgreSQL slow queries and designing indexes
- Application engineers managing production connection limits, timeouts, and transaction isolation
- Data engineers reviewing schema choices and full-text search implementations
- SRE or platform engineers handling job queues and concurrent write workloads
Related Skills
A one-shot coding agent built on Claude Code CLI that runs non-interactively, supports a specified workdir, and can be monitored in the foreground or background.
Preview and confirm file sorting by extension, with recursive cleanup, ignore rules, and transactional rollback.
An engineering assistant for static HTML/CSS/JS pages, design-token extraction, IE8-compatible review, and structured delivery.
An engineering workflow for requirement analysis, scenario modeling, risk planning, quality gates, testing, and knowledge capture, with lightweight, standard, and full modes.