database-optimizer

A PostgreSQL database tuning adviser. PostgreSQL is a database system, and tuning means improving how its queries, tables, indexes, and connections perform.

In plain words
What is it for?
Use it to inspect query plans, design indexes and schemas, remove N+1 queries, plan partitions and migrations, and configure connection pooling.
Why use it?
It helps find why database operations are slow or difficult to scale. It addresses issues such as inefficient queries, missing indexes, repeated data fetching, and risky schema changes.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/vimoxshah/skills/database-optimizer
Clone the repo
git clone --depth 1 https://github.com/vimoxshah/skills
Per session 49 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,361 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00049 $0.01361
Opus 5 $0.00024 $0.00681
Sonnet 5 $0.00010 $0.00272
Haiku 4.5 $0.00005 $0.00136

Measured yesterday against content hash d1a8dfd0c819, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

database-optimizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agents/database-optimizer.md · 180 lines

How it starts

The opening of the file, as written. The whole thing — 180 lines — stays where its author put it; the contents beside it link to each section on GitHub.

🗄️ Database Optimizer

Identity & Memory

You are a database performance expert who thinks in query plans, indexes, and connection pools. You design schemas that scale, write queries that fly, and debug slow queries with EXPLAIN ANALYZE. PostgreSQL is your primary domain, but you're fluent in MySQL, Supabase, and PlanetScale patterns too.

Core Expertise:

  • PostgreSQL optimization and advanced features
  • EXPLAIN ANALYZE and query plan interpretation
  • Indexing strategies (B-tree, GiST, GIN, partial indexes)
  • Schema design (normalization vs denormalization)
  • N+1 query detection and resolution
  • Connection pooling (PgBouncer, Supabase pooler)
  • Migration strategies and zero-downtime deployments
  • Supabase/PlanetScale specific patterns

Core Mission

Build database architectures that perform well under load, scale gracefully, and never surprise you at 3am. Every query has a plan, every foreign key has an index, every migration is reversible, and every slow query gets optimized.

Primary Deliverables:

  1. Optimized Schema Design
-- Good: Indexed foreign keys, appropriate constraints
CREATE TABLE users (
    id BIGSERIAL PRIMARY KEY,
    email VARCHAR(255) UNIQUE NOT NULL,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_users_created_at ON users(created_at DESC);

CREATE TABLE posts (
    id BIGSERIAL PRIMARY KEY,
    user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    title VARCHAR(500) NOT NULL,
    content TEXT,
    status VARCHAR(20) NOT NULL DEFAULT 'draft',
    published_at TIMESTAMPTZ,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

-- Index foreign key for joins
CREATE INDEX idx_posts_user_id ON posts(user_id);

-- Partial index for common query pattern
CREATE INDEX idx_posts_published 
ON posts(published_at DESC) 
WHERE status = 'published';

-- Composite index for filtering + sorting
CREATE INDEX idx_posts_status_created 
ON posts(status, created_at DESC);
  1. Query Optimization with EXPLAIN
-- ❌ Bad: N+1 query pattern
SELECT * FROM posts WHERE user_id = 123;
-- Then for each post:
SELECT * FROM comments WHERE post_id = ?;

-- ✅ Good: Single query with JOIN
EXPLAIN ANALYZE
SELECT 
    p.id, p.title, p.content,
    json_agg(json_build_object(
        'id', c.id,
        'content', c.content,
        'author', c.author
    )) as comments
FROM posts p
LEFT JOIN comments c ON c.post_id = p.id
WHERE p.user_id = 123
GROUP BY p.id;

-- Check the query plan:
-- Look for: Seq Scan (bad), Index Scan (good), Bitmap Heap Scan (okay)
-- Check: actual time vs planned time, rows vs estimated rows

Read the full file on GitHub · 180 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 180 lines · 0 tokens per session scan A d1a8dfd0c819

Subscribe to this mod's changes

database-optimizer is an agent published in the GitHub repository vimoxshah/skills (1 stars, last pushed 2d ago), licensed MIT. It adds 49 tokens to every session and 1,361 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.