postgres-patterns

Provide PostgreSQL query and schema optimization guidance without executing database changes.

1|Updated Mar 7, 2026
One-click install
npx skills add https://github.com/y0ncha/aptitude-client --skill postgres-patterns-y0ncha
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-patterns
Source: https://github.com/y0ncha/aptitude-client/tree/main/.agents/skills/postgres-patterns
Command: npx skills add https://github.com/y0ncha/aptitude-client --skill postgres-patterns-y0ncha

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides concise, actionable PostgreSQL guidance to reduce slow queries, eliminate indexing and schema anti-patterns, and improve security and maintainability for production databases.

Core Features & Use Cases

  • Indexing Guidance: Recommendations for b-tree, GIN, BRIN, composite, covering, and partial indexes to match common query patterns.
  • Schema and Type Best Practices: Advice on choosing data types, timestamp handling, ID strategies, and boolean/monetary field design.
  • Operational Checks and Anti-Patterns: Diagnostic queries and configuration suggestions to detect unindexed foreign keys, slow statements, and table bloat.
  • Use Case: Optimize an orders table with frequent WHERE and range queries by recommending composite or partial indexes, schema tweaks, and configuration tuning to lower latency.

Quick Start

Use the postgres-patterns skill to analyze a slow SQL query and recommend specific index changes, schema adjustments, and configuration settings to reduce execution time.

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 and recommend the right indexes?

To optimize slow PostgreSQL queries, analyze the execution plan and apply indexing guidance for b-tree, GIN, BRIN, composite, covering, or partial indexes. This approach matches common query patterns to lower latency for OLTP and analytical workloads without executing database changes.

What are common PostgreSQL schema design and data type anti-patterns to avoid?

PostgreSQL schema design anti-patterns include poor data type choices, improper timestamp handling, and inefficient ID strategies. Following schema and type best practices for boolean and monetary fields improves maintainability and eliminates structural inefficiencies in production databases.

How do I configure PostgreSQL row level security policies for access control?

Configuring PostgreSQL row level security (RLS) policies involves applying RLS best practices to restrict data access. This provides schema security guidance by defining access rules directly on tables to ensure secure multi-tenant or role-based data isolation.

How can I detect unindexed foreign keys and table bloat in a PostgreSQL database?

Detect unindexed foreign keys and table bloat by running operational diagnostic queries. These checks identify slow statements and structural anti-patterns, providing configuration suggestions to resolve performance degradation in your PostgreSQL database.

Does this PostgreSQL query optimization guidance apply to both OLTP and analytical workloads?

Yes, this PostgreSQL query optimization guidance applies to both OLTP and analytical workloads. It provides index recommendations, schema adjustments, and configuration tuning to satisfy performance requirements across different database workload patterns.

What is the best way to plan PostgreSQL schema migrations without downtime?

The best way to plan PostgreSQL schema migrations is to follow migration planning guidance that evaluates schema tweaks and index changes. This ensures operational checks are met, reducing slow queries and maintaining performance during production database transitions.