postgres-patterns

Provide PostgreSQL patterns for query design, indexing, and security.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL pattern guidance helps database engineers design efficient schemas, optimize queries, and enforce secure practices to improve performance and maintainability.

Core Features & Use Cases

  • Indexing patterns: selecting and tuning B-tree, GIN, and BRIN indexes for common query shapes.
  • Schema design guidance: normalization versus denormalization, appropriate data types, and constraints.
  • Security & RLS: applying row-level security and robust access controls.
  • Migration & performance tactics: upsert patterns, pagination strategies, and bulk data handling for large tables.
  • Use Case: optimize a reporting or analytics database with heavy filtering and aggregations.

Quick Start

Review these patterns and start applying them to your PostgreSQL setup.

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 for heavy filtering and aggregations?

To optimize PostgreSQL query performance, apply curated indexing patterns like composite, partial, and covering indexes, alongside appropriate schema design and normalization strategies to speed up heavy filtering and aggregations.

What is the best way to implement cursor-based pagination in PostgreSQL?

The best way to implement cursor-based pagination in PostgreSQL involves using specific performance patterns that handle large datasets efficiently, avoiding the overhead of traditional offset-based pagination methods.

When do I need row-level security policies in my PostgreSQL database?

You need row-level security policies in PostgreSQL when enforcing robust access controls and restricting data visibility at the row level based on user roles, ensuring secure data isolation across deployments.

How do I perform an upsert safely during PostgreSQL migrations?

To perform an upsert safely during PostgreSQL migrations, apply safe migration templates and upsert patterns that handle bulk data and conflict resolution without disrupting database performance.

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

You should use BRIN indexes instead of B-tree indexes in PostgreSQL when dealing with large tables featuring naturally ordered data, selecting the appropriate index type based on your specific query shapes.

What are the limitations of using covering indexes for query optimization?

Limitations of using covering indexes for query optimization include increased storage overhead and slower write operations, requiring careful evaluation of schema design and query patterns before implementation.