postgres-patterns

Provide PostgreSQL patterns for query optimization, indexing, and security hardening.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps developers avoid slow queries, inefficient schemas, and insecure database setups by providing practical PostgreSQL patterns grounded in indexing, pagination, RLS, and operational configuration.

Core Features & Use Cases

  • Indexing and query optimization: Choose the right index types (B-tree, GIN, BRIN) and design composite, covering, and partial indexes.
  • Performance patterns: Use cursor pagination for scalable reads and safe queue processing to prevent contention.
  • Security defaults with RLS: Implement optimized Row Level Security policies aligned with authentication context.
  • Operational configuration template: Apply baseline connection, timeout, monitoring, and permission hardening settings.

Quick Start

Use postgres-patterns to design an index strategy and RLS policy for a table where queries are slow and access must be restricted by the authenticated user.

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 the right indexing strategy?

PostgreSQL query optimization uses targeted index types like B-tree, GIN, and BRIN to accelerate data retrieval. Designing composite, covering, and partial indexes directly addresses slow query performance by minimizing sequential table scans.

What is cursor pagination and how does it improve PostgreSQL read performance?

Cursor pagination is a PostgreSQL performance pattern that uses indexed cursor positions instead of OFFSET for scalable reads. It prevents the database from scanning increasingly large row counts as users navigate deeper into result sets.

How do I implement Row Level Security (RLS) policies in PostgreSQL?

Row Level Security in PostgreSQL restricts table data access based on authentication context. You implement optimized RLS policies to enforce user-specific data isolation without writing complex application-level filtering logic.

What's the best way to design a PostgreSQL schema for safe queue processing?

Safe PostgreSQL queue processing uses queue locking patterns to prevent contention. This schema design approach ensures reliable concurrent task execution without race conditions or deadlocks during high-throughput operations.

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

BRIN indexes in PostgreSQL are best for large tables with naturally ordered data, offering smaller storage footprints. B-tree indexes remain the standard for precise lookups and composite queries requiring exact matching across multiple columns.

What baseline connection and timeout settings should I apply for PostgreSQL hardening?

PostgreSQL hardening applies baseline operational configuration templates for connections, timeouts, and monitoring. These settings establish secure session parameters and permission boundaries to prevent unauthorized access and resource exhaustion.