database-advanced-optimization

database-advanced-optimization is a skill for Claude Code, Codex from williamzujkowski/standards. It costs 15 tokens per session (4,105 once invoked), scanned A, a copy of graphql-api-design, MIT.

A guide to choosing and tuning PostgreSQL, MongoDB, and Redis databases. It includes examples of indexes, query-plan analysis, aggregation, caching, and other database choices.

In plain words
What is it for?
Use it to choose between relational, document, and in-memory databases, create indexes, inspect query plans, and design caching or session storage.
Why use it?
It helps match a database to the data and consistency needs, then find common ways to improve query speed and response time.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to choose between relational, document, and in-memory databases, create indexes, inspect query plans, and design caching or session storage.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/williamzujkowski/standards/advanced-optimization
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.

Any agent
npx skills add williamzujkowski/standards --skill advanced-optimization
Clone the repo
git clone --depth 1 https://github.com/williamzujkowski/standards

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for database-advanced-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/williamzujkowski/standards/advanced-optimization/github.svg)](https://agentmods.dev/skills/williamzujkowski/standards/advanced-optimization)
Your own site
<a href="https://agentmods.dev/skills/williamzujkowski/standards/advanced-optimization"><img src="https://agentmods.dev/badge/skills/williamzujkowski/standards/advanced-optimization/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for database-advanced-optimization

Your own site · 80×15
<a href="https://agentmods.dev/skills/williamzujkowski/standards/advanced-optimization"><img src="https://agentmods.dev/badge/skills/williamzujkowski/standards/advanced-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 15 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,105 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 94% copy Near-identical to another mod 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.1 $0.00015 $0.04105
Opus 5.5 $0.00006 $0.01642
Sonnet 5.5 $0.00003 $0.00821
Haiku 4.5 $0.00002 $0.00411

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

Security

Grade A, and why

database-advanced-optimization 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.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/query-profiling.sh, templates/redis-caching.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Origin

This is a copy

94% identical to graphql-api-design — 680 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/database/advanced-optimization/SKILL.md · 743 lines

How it starts

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

Database Advanced Optimization

Level 1: Quick Reference (5 minutes)

Database Selection Guide

Use SQL (PostgreSQL) when:

  • ACID compliance is critical
  • Complex joins and transactions required
  • Data has clear relational structure
  • Strong consistency needed
  • Rich query capabilities required

Use NoSQL (MongoDB) when:

  • Flexible schema needed
  • Horizontal scaling is priority
  • Document-oriented data model fits
  • High write throughput required
  • Eventual consistency acceptable

Use In-Memory (Redis) when:

  • Sub-millisecond latency required
  • Caching layer needed
  • Real-time features (pub/sub, streams)
  • Session management
  • Rate limiting or counters

Common Optimization Patterns

-- PostgreSQL: Create covering index
CREATE INDEX idx_orders_user_date ON orders(user_id, created_at)
INCLUDE (status, total_amount);

-- PostgreSQL: Analyze query plan
EXPLAIN (ANALYZE, BUFFERS)
SELECT * FROM orders WHERE user_id = 123;
// MongoDB: Create compound index
db.orders.createIndex({ userId: 1, createdAt: -1 }, { background: true });

// MongoDB: Use aggregation pipeline efficiently
db.orders.aggregate([
  { $match: { status: "pending" } },
  { $sort: { createdAt: -1 } },
  { $limit: 100 }
]);
# Redis: Implement cache-aside pattern
def get_user(user_id):
    cache_key = f"user:{user_id}"
    user = redis.get(cache_key)

    if user is None:
        user = db.query("SELECT * FROM users WHERE id = %s", user_id)
        redis.setex(cache_key, 3600, json.dumps(user))

    return json.loads(user)

Essential Optimization Checklist

PostgreSQL
  • Create appropriate indexes (B-tree, GIN, GiST)
  • Analyze query plans with EXPLAIN ANALYZE
  • Configure autovacuum appropriately
  • Set up connection pooling (PgBouncer)
  • Monitor with pg_stat_statements
  • Optimize shared_buffers and work_mem
  • Configure appropriate WAL settings
MongoDB
  • Design effective shard keys
  • Create compound indexes for common queries
  • Enable profiler for slow queries
  • Configure replica sets for read scaling
  • Optimize aggregation pipelines
  • Set appropriate write concerns
  • Monitor with MongoDB Compass/Atlas

Read the full file on GitHub · 743 lines

Files

What ships with it

8 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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 · 743 lines · 15 tokens per session scan A e7429a9a4238

Subscribe to this mod's changes

database-advanced-optimization is a skill published in the GitHub repository williamzujkowski/standards (18 stars, last pushed 1mo ago), licensed MIT. It adds 15 tokens to every session and 4,105 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 94% identical to graphql-api-design, differing in 680 lines, and is treated as a copy.

Related

Other skills, from other repositories

database-engineer

!cat skills/shared/protocols/ux-protocol.md 2>/dev/null || true !cat skills/shared/protocols/input-validation.md 2>/dev/null || true !cat skills/shared/protocols/tool-efficiency.md 2>/dev/null || true !cat .production-grade.yaml 2>/dev/null || echo "No config — using defaults" !cat .forgewright/codebase-context.md…

buiphucminhtam/forgewright · 45 tokens

database-management-patterns

Comprehensive guide for database management patterns covering PostgreSQL and MongoDB including schema design, indexing, transactions, replication, and performance tuning.

manutej/luxor-claude-marketplace · 31 tokens

PostgreSQL Performance Optimization

Production-grade PostgreSQL query optimization, indexing strategies, performance tuning, and modern features including pgvector for AI/ML workloads. Master EXPLAIN plans, query analysis, and database design for high-performance applications.

bobmatnyc/mcp-skillset · 47 tokens

database-query

Natural language database queries with multi-database support, query optimization, and visual results.

glincker/claude-code-marketplace · 19 tokens

postgresql-expert

Expert-level PostgreSQL database administration, advanced queries, performance tuning, and production operations. Use when the user mentions database, SQL, or performance, or when the task involves Advanced Data Types, Full-Text Search, Advanced Indexes, or Advanced Queries.

personamanagmentlayer/pcl · 56 tokens

database-enumeration

Database service enumeration and quick-win access checks for MSSQL, MySQL, PostgreSQL, Oracle, MongoDB, and Redis. Checks default/empty passwords, unauthenticated access, and command execution capabilities. Use after network-recon identifies database ports.

blacklanternsecurity/red-run · 56 tokens