postgresql

Optimize PostgreSQL databases with indexing, partitioning, and query tuning.

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/mefardales/skillbox --skill postgresql-mefardales
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql
Source: https://github.com/mefardales/skillbox/tree/main/skills/data/postgresql
Command: npx skills add https://github.com/mefardales/skillbox --skill postgresql-mefardales

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides advanced strategies and patterns for building, optimizing, and managing PostgreSQL databases in production environments, moving beyond basic schema design.

Core Features & Use Cases

  • Data Type Optimization: Guidance on choosing the most efficient data types (UUID, JSONB, ARRAY, ENUM, INET).
  • Indexing Strategies: Detailed explanations and examples for B-tree, GIN, GiST, BRIN, partial, and expression indexes.
  • Query Optimization: Techniques using EXPLAIN ANALYZE, CTEs, and window functions.
  • Partitioning: Implementing range and list partitioning for large tables.
  • Full-Text Search: Leveraging tsvector, tsquery, and pg_trgm for efficient text searching.
  • Connection Pooling: Recommendations for using PgBouncer.
  • Backup Strategies: Overview of pg_dump, pg_basebackup, and WAL archiving.
  • Row-Level Security: Implementing multi-tenant data isolation.
  • Essential Extensions: Usage of pg_trgm, pg_stat_statements, and postgis.

Quick Start

Use the postgresql skill to create an index on the 'created_at' column of the 'orders' table.

Frequently Asked Questions about postgresql

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

FAQPage Schema
How do I optimize slow PostgreSQL queries in production?

Optimize slow PostgreSQL queries by analyzing execution plans with EXPLAIN ANALYZE, leveraging CTEs and window functions, and applying B-tree, GIN, or GiST indexing strategies to improve data retrieval performance.

What is the best way to scale large PostgreSQL tables?

Scale large PostgreSQL tables by implementing range and list partitioning, which divides massive datasets into smaller, manageable chunks to maintain query performance and simplify data management.

How does full-text search work in PostgreSQL?

Full-text search in PostgreSQL works by leveraging tsvector and tsquery data types alongside GIN indexes and pg_trgm extension to perform efficient and rapid text searching across stored documents.

Can I enforce multi-tenant data isolation directly in PostgreSQL?

Enforce multi-tenant data isolation directly in PostgreSQL by implementing row-level security policies, ensuring tenants only access their authorized rows without complex application-level filtering logic.

When should I use partial or expression indexes in PostgreSQL?

Use partial indexes to optimize queries targeting specific subsets of data, reducing index size and maintenance overhead, and expression indexes to pre-compute results for queries filtering on computed values.

What PostgreSQL backup strategies are recommended for production?

Recommended PostgreSQL backup strategies for production include using pg_dump for logical backups, pg_basebackup for physical backups, and continuous WAL archiving for point-in-time recovery.