postgres-patterns

Apply PostgreSQL patterns to optimize queries and design schemas.

1.8k|303|Updated Jan 27, 2026
One-click install
npx skills add https://github.com/xu-xiang/everything-claude-code-zh --skill postgres-patterns-xu-xiang
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-patterns
Source: https://github.com/xu-xiang/everything-claude-code-zh/tree/main/docs/zh-TW/skills/postgres-patterns
Command: npx skills add https://github.com/xu-xiang/everything-claude-code-zh --skill postgres-patterns-xu-xiang

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides practical PostgreSQL patterns for query optimization, schema design, indexing, and security based on best practices.

Core Features & Use Cases

  • Indexing strategies: choose the right index types (B-tree, GIN, BRIN) for common query patterns.
  • Schema design & constraints: guidance on table design, constraints, normalization, and denormalization trade-offs.
  • Security & performance: recommend Row Level Security and performance tuning tips for scalable databases.
  • Use Case: When optimizing a slow query, apply the patterns to rewrite the query, choose appropriate indexes, and verify costs.

Quick Start

Use this skill to review and apply PostgreSQL patterns to your database schema and queries. For example, design an indexing strategy for a multi-column filter and enable RLS for row-level access control.

Frequently Asked Questions about postgres-patterns

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

FAQPage Schema
How do I choose the right PostgreSQL index type for my query patterns?

Choosing the right PostgreSQL index type depends on your query patterns: B-tree handles standard equality and range queries, GIN accelerates full-text search and array containment, and BRIN efficiently indexes large tables with naturally sorted data.

When do I need Row Level Security in PostgreSQL schema design?

You need Row Level Security (RLS) in PostgreSQL when multi-tenant applications require strict row-level access control. Enabling RLS ensures users only query and modify data rows they are explicitly authorized to access based on defined policies.

What is the best way to optimize slow PostgreSQL queries?

The best way to optimize slow PostgreSQL queries involves rewriting inefficient SQL, selecting appropriate index types like B-tree or GIN for multi-column filters, and verifying execution costs to ensure scalable database performance.

How does normalization vs denormalization affect PostgreSQL schema design trade-offs?

Normalization vs denormalization in PostgreSQL schema design trade-offs involves balancing data integrity against query performance. Normalization reduces redundancy through constraints, while denormalization improves read speed by accepting controlled data duplication.

Can I apply these PostgreSQL optimization patterns to an existing database?

You can apply these PostgreSQL optimization patterns to an existing database by incrementally adding appropriate indexes, enabling Row Level Security, and modifying table constraints without requiring a complete schema redesign.