postgresql

Apply PostgreSQL patterns for query optimization, concurrency control, and safe migrations.

Updated Mar 18, 2025
One-click install
npx skills add https://github.com/zzoohub/mealio --skill postgresql-zzoohub
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql
Source: https://github.com/zzoohub/mealio/tree/main/.claude/skills/postgresql
Command: npx skills add https://github.com/zzoohub/mealio --skill postgresql-zzoohub

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL problem-solving patterns for production systems. This section describes how to identify performance bottlenecks, concurrency issues, and migration challenges in real-world PostgreSQL deployments, and how to apply proven patterns to address them.

Core Features & Use Cases

  • Cursor-based pagination: avoids slow OFFSET scans by paging on (created_at, id) with a stable order.
  • Indexing & query tuning: guidelines for using BRIN, GIN, and expression indexes to accelerate common queries.
  • Safe migrations: strategies for zero-downtime migrations using NOT VALID/VALIDATE and batched backfills.
  • Concurrency strategies: approaches for high-concurrency updates, SKIP LOCKED, and batching to reduce contention.
  • Time-series and data modeling: patterns for partitioning and efficient data organization at scale.

Quick Start

Identify a slow-producing query in your production workload and implement a cursor-based pagination or an indexing strategy described above to observe measurable improvements.

Frequently Asked Questions about postgresql

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

FAQPage Schema
How do I implement cursor-based pagination in PostgreSQL to avoid slow OFFSET scans?

Cursor-based pagination in PostgreSQL avoids slow OFFSET scans by paging on the (created_at, id) tuple with a stable sort order. This pattern fetches subsequent pages efficiently without re-scanning skipped rows in large datasets.

What is the best way to run zero-downtime PostgreSQL migrations on a high-traffic database?

Zero-downtime PostgreSQL migrations use strategies like adding constraints using NOT VALID then applying VALIDATE concurrently, alongside batched data backfills. This prevents table locks and maintains production reliability during schema changes.

When should I use BRIN, GIN, or expression indexes for query tuning in PostgreSQL?

Use BRIN indexes for large tables with natural ordering, GIN indexes to accelerate complex queries like full-text search, and expression indexes to optimize queries filtering by computed values, targeting specific query bottleneck patterns.

How do I handle high-concurrency updates in PostgreSQL without causing contention?

High-concurrency PostgreSQL updates require strategies like utilizing SKIP LOCKED for queue processing and batching transactions. These approaches reduce row contention and improve throughput under heavy concurrent workloads.

Does this approach apply to time-series data modeling and partitioning in PostgreSQL?

Yes, the approach applies to time-series data modeling in PostgreSQL by providing specific patterns for table partitioning and efficient data organization at scale to manage large datasets and high-traffic workloads effectively.