postgres-patterns

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides best practices and quick references for optimizing PostgreSQL database performance, schema design, indexing, and security, helping developers write more efficient and robust SQL.

Core Features & Use Cases

  • Query Optimization: Guidance on writing efficient SQL queries.
  • Schema Design: Best practices for data types and table structures.
  • Indexing Strategies: Recommendations for creating effective indexes (B-tree, GIN, BRIN, composite, covering, partial).
  • Security: Tips for implementing Row Level Security (RLS).
  • Use Case: When designing a new table, use this Skill to select the most appropriate data types and plan your indexing strategy to ensure fast query performance.

Quick Start

Provide guidance on creating a composite index for a table with columns 'user_id' and 'created_at' where 'user_id' is used for equality checks and 'created_at' for range queries.

Frequently Asked Questions about postgres-patterns

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

FAQPage Schema
What's the best way to create a composite index in PostgreSQL for equality and range queries?

When creating a composite PostgreSQL index for equality and range queries, place the equality column first, followed by the range column. This structure allows the index to efficiently filter exact matches before scanning the sorted range.

How do I design a PostgreSQL schema with the right data types for fast query performance?

Designing a PostgreSQL schema for fast performance requires selecting the most appropriate data types and planning your indexing strategy. Applying Supabase best practices ensures efficient table structures and robust database operations.

When should I use partial or covering indexes instead of standard B-tree indexes in PostgreSQL?

Partial or covering PostgreSQL indexes should be used instead of standard B-tree indexes when you need to optimize specific query subsets or avoid table lookups. Partial indexes filter rows by conditions, while covering indexes include extra columns.

How does Row Level Security work for restricting data access in a PostgreSQL database?

Row Level Security in a PostgreSQL database restricts data access by attaching security policies directly to tables. These policies evaluate user attributes for each row, ensuring users only see or modify the data they are authorized to access.

Can I use Supabase connection pooling best practices to optimize slow PostgreSQL queries?

Yes, you can optimize slow PostgreSQL queries using Supabase connection pooling best practices. This Skill provides troubleshooting patterns for inefficient SQL, indexing recommendations, and connection pooling setup to resolve performance bottlenecks.

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

BRIN indexes for PostgreSQL query optimization are limited to naturally ordered data, such as time-series tables. They store block range summaries instead of individual row pointers, making them highly space-efficient but slower for uncorrelated data retrieval.