Postgres Pro
Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features.
Before & after
Same prompt, same agent — the only difference is the skill.
I can help you speed up that query. There are a few common things to check — you might be missing indexes, the query plan might be inefficient, or there could be locking issues. I'd recommend running EXPLAIN ANALYZE on the query to see where the time is being spent. Once we understand the bottleneck, we can add indexes or restructure the query. What's the query you're working with? Database size would also help me give better advice.
POSTGRES QUERY OPTIMIZATION QUERY SUBMITTED: SELECT u.name, p.title, count(c.id) FROM users u JOIN posts p ON u.id = p.user_id LEFT JOIN comments c ON p.id = c.post_id WHERE created_at > now() - interval '30 days' GROUP BY u.id, p.id; EXPLAIN ANALYZE OUTPUT (execution time 4200ms, 850MB peak memory) Seq Scan on posts p (cost 0..1200000 rows=980000) Seq Scan on comments c (cost 0..850000 rows=2100000) ← BOTTLENECK Hash Join DIAGNOSIS: 1. No index on comments.post_id — every group by triggers table scan 2. No index on created_at filter — scans entire posts table even for 30-day window 3. LEFT JOIN pulls all comments regardless of date window — exploding result set OPTIMIZATION STEPS (in order): 1. ADD INDEXES (5 min, zero downtime with CONCURRENTLY) CREATE INDEX CONCURRENTLY idx_comments_post_id ON comments(post_id); CREATE INDEX CONCURRENTLY idx_posts_created_at ON posts(created_at DESC); CREATE INDEX CONCURRENTLY idx_posts_user_created ON posts(user_id, created_at) INCLUDE (id); 2. RESTRUCTURE QUERY (push date filter down) SELECT u.name, p.title, count(c.id) FROM posts p JOIN users u ON p.user_id = u.id LEFT JOIN comments c ON p.id = c.post_id AND c.created_at > now() - interval '30 days' WHERE p.created_at > now() - interval '30 days' GROUP BY u.id, p.id; ← Date filter on LEFT JOIN prevents full table scan of all comments 3. DENORMALIZE IF QUERY RUNS 1000x/day Add posts.comment_count_30d → update via trigger on comment insert/delete Eliminate the LEFT JOIN entirely in read-heavy scenarios EXPECTED RESULT: 4200ms → 180ms (23x speedup) New plan: Index Scan on idx_posts_created_at → Nested Loop Join → Index Scan on idx_comments_post_id VERIFY: Run ANALYZE posts; ANALYZE comments; then re-run EXPLAIN ANALYZE to confirm
About this skill
name: postgres-pro description: Use when Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features.
Postgres Pro
Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features. Invoke for EXPLAIN analysis, JSONB operations, extension usage, VACUUM tuning, performance monitoring.
What you get
- Public GitHub repo
- the skills/postgres-pro folder with SKILL.md and references.
Customize your output
- Fork the repo and extend the skill's reference files for your own stack conventions.
Example output
Activates on a matching request (e.g. building or reviewing Postgres Pro code) and can chain with other skills in the pack.
Best for
Full-stack developers and engineering teams using Claude Code.
SKILL.md preview
---
name: postgres-pro
description: Use when optimizing PostgreSQL queries, configuring replication, or implementing advanced database features such as JSONB, extensions, or VACUUM tuning.
version: 1.0.0
category: Development / Languages
author: AgentVolt
license: proprietary
tags:
- development
- languages
---
# Postgres Pro
Handles PostgreSQL performance and operations: query optimization, replication, JSONB modeling, extensions, and autovacuum tuning.
## When to use
… (sign up to view the full skill)Featured in
More development skills
View all Development skills →SQL Pro
Optimizes SQL queries, designs database schemas, and troubleshoots performance issues.
Csharp Developer
Use when building C# applications with .NET 8+, ASP.NET Core APIs, or Blazor web apps.
Rust Engineer
Writes, reviews, and debugs idiomatic Rust code with memory safety and zero-cost abstractions.
PHP Pro
Use when building PHP applications with modern PHP 8.3+ features, Laravel, or Symfony frameworks.