postgres-patterns

Optimize PostgreSQL queries, schema design, and security with curated patterns.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/robinxin/AIFlomo --skill postgres-patterns-robinxin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-patterns
Source: https://github.com/robinxin/AIFlomo/tree/main/.claude/skills/postgres-patterns
Command: npx skills add https://github.com/robinxin/AIFlomo --skill postgres-patterns-robinxin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL performance, schema design, and security patterns to streamline query optimization, robust data models, and safer access controls.

Core Features & Use Cases

  • Index patterns for fast lookups (B-tree, BRIN, GIN, partial indexes) and practical guidance.
  • Data modeling and security patterns, including RLS policies and safe migrations.
  • Common operational patterns: UPSERT, cursor pagination, and queue processing for reliable workloads.

Quick Start

Apply the patterns to your existing PostgreSQL schema to begin optimizing queries and enforcing security.

Frequently Asked Questions about postgres-patterns

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

FAQPage Schema
How do I optimize PostgreSQL query performance using the right index types?

To optimize PostgreSQL query performance, you apply specific index patterns like B-tree for standard lookups, BRIN for large ordered tables, and GIN for multi-value columns. Selecting the correct index type drastically reduces query latency.

How do I write Row-Level Security policies in PostgreSQL to enforce data access controls?

Writing Row-Level Security (RLS) policies in PostgreSQL involves defining access rules directly on tables to restrict visible rows per user. Applying these security patterns enforces robust data models and safer access controls without changing application queries.

What is the best way to implement UPSERT semantics in PostgreSQL for reliable workloads?

The best way to implement UPSERT semantics in PostgreSQL is using the ON CONFLICT clause within your INSERT statements. This operational pattern ensures reliable workloads by safely updating existing rows or inserting new ones without race conditions.

When do I need a partial index versus a standard B-tree index in PostgreSQL?

You need a partial index in PostgreSQL when queries frequently target a specific subset of rows, whereas a standard B-tree index covers all rows. Using partial indexes saves disk space and accelerates filtered lookups.

How do I perform safe database migrations in PostgreSQL without locking production tables?

Performing safe migrations in PostgreSQL requires applying specific patterns that avoid long table locks, such as adding columns with defaults or expanding constraints gradually. These practices ensure safer access controls and reliable workloads during schema refactoring.

Can I use cursor pagination in PostgreSQL to handle large datasets efficiently?

Cursor pagination in PostgreSQL handles large datasets efficiently by using indexed columns for fetching subsequent records instead of OFFSET. This operational pattern maintains fast query performance as your dataset grows.