postgres-query-optimization

Analyzes slow PostgreSQL queries using EXPLAIN ANALYZE to recommend index and query optimizations.

1|Updated Dec 4, 2025
One-click install
npx skills add https://github.com/francanete/fran-marketplace --skill postgres-query-optimization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-query-optimization
Source: https://github.com/francanete/fran-marketplace/tree/main/database-expert/skills/postgres-query-optimization
Command: npx skills add https://github.com/francanete/fran-marketplace --skill postgres-query-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a reference guide for PostgreSQL query optimization and performance tuning. It helps you analyze slow queries, interpret EXPLAIN output, optimize indexes, and troubleshoot database performance issues.

Core Features & Use Cases

  • EXPLAIN interpretation and plan analysis to identify bottlenecks
  • Index design guidance and optimization strategies
  • Query rewrite and plan tuning recommendations for common patterns (N+1, large scans, slow joins)
  • Production-grade performance troubleshooting with practical checklists and best practices

Quick Start

Run EXPLAIN ANALYZE on a slow query and review the suggested indexing and plan improvements to reduce execution time.

Frequently Asked Questions about postgres-query-optimization

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

FAQPage Schema
How do I analyze PostgreSQL EXPLAIN output to find slow query bottlenecks?

PostgreSQL query optimization uses EXPLAIN ANALYZE to expose execution plan bottlenecks like sequential scans and N+1 patterns. This skill interprets those results to pinpoint performance issues such as large scans and slow joins, guiding targeted query optimization.

What's the best way to design indexes for PostgreSQL performance tuning?

Index design for PostgreSQL performance tuning requires matching index strategies to specific query patterns. This skill provides concrete index suggestions based on your execution plans, helping eliminate large scans and resolve slow joins in production databases.

How do I fix N+1 query problems and slow joins in PostgreSQL?

Fixing N+1 queries and slow joins in PostgreSQL requires query rewrites and proper indexing. This skill analyzes your execution plans to provide concrete query rewrite recommendations that eliminate these common performance bottlenecks.

Can I use this for production database troubleshooting and configuration tuning?

Production database troubleshooting and configuration tuning are supported through practical checklists and best practices. This skill delivers concrete configuration tuning steps alongside index suggestions and query rewrites based on EXPLAIN ANALYZE results.

When should I not add a new index to optimize a slow PostgreSQL query?

You should avoid adding indexes when query rewrites or configuration tuning can resolve the bottleneck instead. This skill weighs index design against query rewrite recommendations, ensuring you apply the correct optimization strategy for your specific execution plan.