postgres

Designs and tunes PostgreSQL schemas, indexes, queries, transactions, and operations.

22|Updated Sep 10, 2026
One-click install
npx skills add https://github.com/Lynricsy/HyperSkills --skill postgres-lynricsy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres
Source: https://github.com/Lynricsy/HyperSkills/tree/main/skills/postgres
Command: npx skills add https://github.com/Lynricsy/HyperSkills --skill postgres-lynricsy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? PostgreSQL performance and correctness problems — slow queries, dangerous migrations on live tables, leaking row-level security policies, and connection pool failures — usually stem from subtle version-specific behaviors that generic advice gets wrong. This Skill provides verified, version-gated rules and diagnostic workflows for PostgreSQL 14 through 18. ## Core Features & Use Cases - Query and index tuning: Read EXPLAIN (ANALYZE, BUFFERS) plans per-loop, fix estimate errors with extended statistics, and choose composite, partial, expression, or covering indexes based on operator and predicate order. - Safe online schema changes: Classify every DDL statement by lock level and rewrite behavior, split migrations into separately committed steps, use NOT VALID constraints and CREATE INDEX CONCURRENTLY, and batch backfills by primary key. - RLS, pooling, and diagnostics: Write row-level security policies with correct USING/WITH CHECK semantics, survive transaction-mode poolers like PgBouncer, and answer "why is it slow" with pg_stat catalogue queries. - Use Case: A migration adds a column with a volatile default and a bare CREATE INDEX on a 180M-row production table. The Skill flags the ACCESS EXCLUSIVE lock queue, the full table rewrite, and the blocked writes, then rewrites the file into safe separately-committed steps. ## Quick Start Review my PostgreSQL migration file and slow query plan, then tell me which statements are dangerous on a live table and which indexes to create or drop.

Frequently Asked Questions about postgres

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a column or index to a large PostgreSQL table without downtime?

Adding a column with a non-volatile default is a catalogue-only change, but a volatile default rewrites the whole table. Use CREATE INDEX CONCURRENTLY outside any transaction block, add constraints as NOT VALID then VALIDATE CONSTRAINT, and set a short lock_timeout with retries.

How do I fix a slow PostgreSQL query using EXPLAIN?

Run EXPLAIN (ANALYZE, BUFFERS) and read it per-loop, multiplying node times by the loops count. Compare estimated versus actual rows to fix statistics first, then choose indexes based on the predicate's operator and column order rather than adding indexes blindly.

Why does my PostgreSQL RLS policy leak rows or run slowly?

Table owners bypass RLS unless FORCE ROW LEVEL SECURITY is set, and permissive policies OR together so one loose policy widens all others. For performance, index policy columns and wrap function calls as (SELECT f()) when the predicate lands in a Filter node.

Does PgBouncer transaction mode break prepared statements and session state?

Yes, transaction-mode pooling breaks session SET, SQL-level PREPARE, LISTEN/NOTIFY, and session advisory locks, producing errors that never mention pooling. Use PgBouncer 1.21+ max_prepared_statements for protocol-level prepared statements and SET LOCAL for request context.

When should I use JSONB versus real columns in PostgreSQL?

Any value you filter, sort, join, or constrain on should be a real column, not a JSONB key, because GIN indexes do not accelerate ->> equality and jsonb_set rewrites the whole row. Promote hot fields with a stored generated column while keeping the JSONB payload.

What are the limits of pgvector HNSW indexes in PostgreSQL?

HNSW refuses columns over 2000 dimensions, and the index operator class must match the query's distance operator or the index is silently ignored. For 3072-dimension embeddings, index a halfvec cast; tune recall with hnsw.ef_search and iterative scan for filtered queries.