postgres-patterns

Apply PostgreSQL indexing, schema, RLS, and upsert patterns for performance and security.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.

Core Features & Use Cases

  • Indexing strategies for B-tree, BRIN, GIN, and composite indexes to speed up where clauses and lookups.
  • Data-type and schema design guidance to improve storage efficiency and robustness.
  • Security and policy guidance, including RLS optimizations and safe configuration templates.
  • Use Case: When designing a new schema or optimizing slow queries, apply these patterns to achieve faster responses and more secure access control.

Quick Start

Review your current PostgreSQL design and queries and apply the supplied indexing, data-type, RLS, and upsert patterns to improve performance and 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 slow PostgreSQL queries with indexing strategies?

Optimize slow PostgreSQL queries by applying targeted indexing strategies. This includes using B-tree for standard lookups, BRIN for large sorted datasets, and GIN indexes for multi-value columns to accelerate where clauses.

What are the best practices for PostgreSQL schema design and data-type selection?

PostgreSQL schema design best practices involve selecting appropriate data-types to improve storage efficiency and robustness. Applying proven database patterns during initial design prevents structural anti-patterns and ensures long-term performance.

How do I configure Row Level Security policies in PostgreSQL safely?

Configure Row Level Security (RLS) policies safely by applying security defaults and optimized policy patterns. These patterns ensure secure access control while maintaining query performance across common operational scenarios.

Does this approach provide PostgreSQL upsert patterns and safe configuration templates?

Yes, this approach provides PostgreSQL upsert patterns and safe configuration templates. These enforce guidance for performance-oriented operations, security defaults, and safe configuration across common database scenarios.

When should I use BRIN versus GIN indexes for PostgreSQL query optimization?

Use BRIN indexes for large PostgreSQL datasets with naturally sorted physical order to save space, and deploy GIN indexes for columns containing multiple values or complex data types to accelerate lookups.

Why does my PostgreSQL database suffer from anti-patterns and how can I detect them?

PostgreSQL database anti-patterns cause poor performance and storage bloat. Detect and resolve them by applying proven database patterns that enforce performance-oriented schema design and optimized query structures.