postgres-patterns

Guide PostgreSQL schema design, optimization, and security with common patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pattern-driven guidance for PostgreSQL database design, optimization, and security to help engineers apply best practices and avoid common pitfalls.

Core Features & Use Cases

  • Indexing patterns: b-tree, GIN, BRIN, partial and covering indexes to boost query performance.
  • Data-type guidance: selecting appropriate types for storage efficiency and correctness.
  • Anti-pattern detection: identify common slow queries, missing constraints, and unnecessary indexes.
  • RLS and security: guidelines for row-level security policies and access control strategies.
  • Upsert and concurrency: robust patterns for UPSERT, locking strategies, and error handling.

Quick Start

Provide a pattern-driven review of a given PostgreSQL schema and return a set of index, data-type, and policy patterns to optimize performance and security.

Frequently Asked Questions about postgres-patterns

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

FAQPage Schema
What are the best PostgreSQL indexing patterns for optimizing slow queries?

PostgreSQL indexing patterns include b-tree, GIN, BRIN, partial, and covering indexes to boost query performance. Selecting the correct index type targets specific query structures and data distributions to accelerate data retrieval and reduce scan overhead.

How do I implement row-level security policies in PostgreSQL?

Row-level security RLS in PostgreSQL is implemented through access control policies that restrict data visibility at the row level. Applying RLS patterns ensures secure multi-tenant applications by enforcing data isolation directly within the database layer.

What is the pattern for handling UPSERT operations and concurrency in PostgreSQL?

The PostgreSQL UPSERT pattern handles concurrency through robust locking strategies and error handling during insert-or-update operations. This approach prevents race conditions and ensures data integrity when multiple transactions modify the same records.

How do I detect common anti-patterns in my PostgreSQL schema design?

Detecting PostgreSQL anti-patterns involves identifying slow queries, missing constraints, and unnecessary indexes during a schema review. This pattern-driven analysis exposes common database design flaws that degrade performance and compromise data correctness.

When should I use BRIN indexes instead of b-tree indexes in PostgreSQL?

BRIN indexes in PostgreSQL suit large tables with naturally sorted data, offering smaller storage footprints than b-tree indexes. B-tree remains the standard pattern for exact value lookups and uncorrelated data distributions where block-level range summaries are inefficient.

How do I select appropriate PostgreSQL data types for storage efficiency?

Selecting PostgreSQL data types for storage efficiency requires matching column formats to data characteristics and access patterns. Appropriate type selection prevents data truncation, minimizes disk usage, and ensures query correctness across the database schema.