postgres-patterns

Optimize PostgreSQL schemas, indexes, and RLS policies for performance.

Updated May 4, 2026
One-click install
npx skills add https://github.com/gganbukim1/myskills --skill postgres-patterns-gganbukim1
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-patterns
Source: https://github.com/gganbukim1/myskills/tree/main/postgres-patterns
Command: npx skills add https://github.com/gganbukim1/myskills --skill postgres-patterns-gganbukim1

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Helps you design schemas and indexes that improve PostgreSQL query performance while strengthening database security practices like Row Level Security.

Core Features & Use Cases

  • Index and data-type selection: Choose the right index type (B-tree, GIN, BRIN) and appropriate column types to reduce slow scans and unnecessary casts.
  • Schema and query optimization patterns: Apply composite ordering, covering indexes, partial indexes, cursor pagination, and queue-safe processing.
  • Security and operations guidance: Implement optimized RLS policies, upserts, and sensible connection and timeout configuration defaults.

Quick Start

Ask the postgres-patterns skill to suggest the best index strategy and RLS policy approach for a slow query and an orders table in your Supabase PostgreSQL database.

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 in a Supabase database?

PostgreSQL query optimization improves by selecting appropriate index types like B-tree, GIN, or BRIN, and applying composite ordering or covering indexes. This approach reduces slow scans and unnecessary casts in your Supabase production database.

What is the best way to implement Row Level Security policies in PostgreSQL?

Implementing Row Level Security policies requires applying optimized RLS policy semantics tailored to Supabase best practices. This ensures safe access control and strengthens database security without degrading query performance.

When do I need a partial index versus a composite index in PostgreSQL?

Partial indexes optimize queries filtering specific subsets of data, while composite indexes improve multi-column sorting and filtering. Applying correct index ordering rules and composite ordering reduces slow scans in PostgreSQL.

Does this PostgreSQL schema design guidance apply to background job and queue processing?

Yes, PostgreSQL schema design guidance includes queue-safe processing patterns for background jobs. Applying these query patterns ensures safe concurrent processing and efficient data handling within your production database architecture.

What are the limitations of using BRIN indexes for query optimization in PostgreSQL?

BRIN indexes are limited to naturally ordered data sets, offering smaller size but less precision than B-tree indexes. Understanding correct Postgres index types and index ordering rules prevents inefficient slow scans in PostgreSQL.