postgres-patterns

Provide PostgreSQL optimization patterns for indexing, schema design, and configuration.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers and database administrators optimize their PostgreSQL database schemas, queries, and configurations to improve performance, security, and maintainability.

Core Features & Use Cases

  • Indexing Strategies: Provides guidance on creating effective B-tree, GIN, BRIN, and composite indexes.
  • Data Type Selection: Recommends appropriate data types for various use cases to ensure data integrity and efficiency.
  • Pattern Implementation: Demonstrates best practices for common SQL patterns like UPSERT, cursor pagination, and queue processing.
  • Anti-Pattern Detection: Includes SQL queries to identify common performance pitfalls such as unindexed foreign keys and table bloat.
  • Configuration Tuning: Offers a template for essential PostgreSQL configuration parameters.

Quick Start

Use the postgres-patterns skill to generate an optimized index for a table with a JSONB column.

Frequently Asked Questions about postgres-patterns

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

FAQPage Schema
How do I optimize PostgreSQL schema design and queries for better performance?

To optimize PostgreSQL schema design and queries, you should apply best practices for data type selection, implement effective indexing strategies like B-tree or GIN, and use proper SQL patterns to ensure data integrity and efficiency.

What's the best way to choose PostgreSQL index types for specific database use cases?

Choosing PostgreSQL index types depends on your query patterns: use B-tree for standard lookups, GIN for JSONB or full-text search, BRIN for large sorted tables, and composite indexes for multi-column filtering to optimize database performance.

How can I detect common PostgreSQL anti-patterns like unindexed foreign keys and table bloat?

You can detect PostgreSQL anti-patterns like unindexed foreign keys and table bloat by running specific SQL queries designed to identify these common performance pitfalls, allowing you to proactively resolve database bottlenecks.

Does this PostgreSQL optimization guidance work with Supabase database configurations?

Yes, the PostgreSQL optimization guidance is based on Supabase best practices, offering configuration templates and SQL pattern implementations that align directly with Supabase database environments to ensure secure and maintainable setups.

How do I implement cursor pagination and UPSERT patterns in PostgreSQL?

To implement cursor pagination and UPSERT patterns in PostgreSQL, follow established SQL best practices that demonstrate how to safely insert or update records and paginate large datasets without performance degradation.