postgres-patterns

Provide PostgreSQL optimization best practices for queries, schemas, indexes, and security.

Updated Jul 10, 2025
One-click install
npx skills add https://github.com/nubiv/my-nome --skill postgres-patterns-nubiv
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-patterns
Source: https://github.com/nubiv/my-nome/tree/main/nix-darwin/config/claude/skills/postgres-patterns
Command: npx skills add https://github.com/nubiv/my-nome --skill postgres-patterns-nubiv

SYSTEM DOCUMENTATION & REQUIREMENTS

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 B-tree, GIN, BRIN, composite, covering, and partial indexes.
  • Security: Examples for Row Level Security (RLS) policies.
  • Performance Tuning: Tips for connection pooling, statement timeouts, and monitoring.
  • Use Case: When encountering slow query performance, consult this Skill for index recommendations or to identify anti-patterns like unindexed foreign keys.

Quick Start

Use the postgres-patterns skill to generate a composite index for a table with equality and range columns.

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 query performance?

To optimize slow PostgreSQL query performance, apply indexing strategies like composite or covering indexes, avoid SQL anti-patterns like unindexed foreign keys, and configure statement timeouts to isolate bottlenecks.

What are the best practices for PostgreSQL indexing strategies?

PostgreSQL indexing strategies best practices involve choosing appropriate index types like B-tree, GIN, or BRIN, and using composite, covering, or partial indexes to match specific query patterns and improve data retrieval speed.

When do I need to use GIN indexes in PostgreSQL?

You need to use GIN indexes in PostgreSQL when optimizing queries involving complex data types or full-text search, as they provide efficient access for these structures compared to standard B-tree indexes.

How do I design a PostgreSQL schema for better database performance?

To design a PostgreSQL schema for better database performance, follow best practices for selecting appropriate data types and structuring tables efficiently to reduce overhead and improve query execution.

How do I configure Row Level Security policies in PostgreSQL?

Configuring Row Level Security policies in PostgreSQL involves defining specific access rules directly on tables to restrict data visibility, requiring an understanding of PostgreSQL security features and SQL syntax.

Do I need SQL syntax knowledge to use PostgreSQL optimization techniques?

Yes, you need SQL syntax knowledge and an understanding of PostgreSQL-specific features to apply optimization techniques, as implementing schema designs, indexes, and security configurations requires writing accurate database code.