Skip to main content

DevOps & Security

Query Performance Analyzer

Analyzes SQL and NoSQL queries for missing indexes, N+1 patterns, full table scans, and suboptimal joins, returning EXPLAIN annotations and optimizations. Useful for preventing slow-query production incidents. Full-stack and backend engineers shipping data-access code, platform teams enforcing performance budgets, and startup CTOs whose teams lack a database specialist. AI agents write syntactically correct SQL that routinely misses indexes, re-queries in loops, or forces full scans on tables that had perfectly good selective indexes available. Developers without deep database experience lack the tooling to diagnose these issues until they surface as p99 latency regressions — at which point the fix is disruptive. A pre-ship analyzer catches the common cases in seconds.

Nexus CertifiedClaude CodeCodexOpenClawGoogle Antigravity
databaseperformancesqloptimizationindexing

One-Time Purchase

$19.99

Sample Output

Query Performance Analysis — listRecentOrdersWithItems

Engine: Postgres 15 · Source: src/api/orders.ts:42 (Drizzle ORM)

Verdict

N+1 + missing composite index — p95 38s on production-shaped data. The handler issues one query to list 50 orders, then 50 sequential per-order SELECT items WHERE order_id = ? round-trips. The per-order subquery hits no usable index (items is indexed on id only). Replacing with a single JOIN and adding items(order_id, created_at) brings p95 from 38s to ~280ms on the same data.

Current query — cost / rows / time

round-trips per request (1 + N)51
rows scanned (Seq Scan on `items` × 50)~140k
measured p95 latency (staging, 250k orders)38s
connection-pool pressure under loadcritical
FindingCurrentTarget
Round-trips511
p95 latency38s~280ms
Access pathSeq ScanComposite index

Current Query

// src/api/orders.ts:42
const orders = await db.select().from(orders)
  .where(eq(orders.userId, userId))
  .orderBy(desc(orders.createdAt))
  .limit(50);

for (const order of orders) {
  order.items = await db.select().from(items).where(eq(items.orderId, order.id));
}

The Drizzle output: 51 separate statements, no JOIN.

Limit  (cost=0.43..3.10 rows=50 width=128)
  ->  Index Scan Backward using orders_user_created_idx on orders
        Index Cond: (user_id = $1)
-- then 50 × :
Seq Scan on items  (cost=0.00..18452.40 rows=2 width=84)
  Filter: (order_id = $1)
  Rows Removed by Filter: 419998

The per-item Seq Scan is the bottleneck — items has 420k rows and no index on order_id.


Plan Compare

Before

N+1 + Seq Scan on items

51 round-trips, no usable index

round-trips51
items access pathSeq Scan
rows touched~140k
38sp95 latency

After

Single JOIN with composite index

One query, Index Scan on items

round-trip1
items(order_id, created_at)Index Scan
rows touched~310
280msp95 latency

Recommended Rewrite

const rows = await db
  .select({
    order: orders,
    item: items,
  })
  .from(orders)
  .leftJoin(items, eq(items.orderId, orders.id))
  .where(eq(orders.userId, userId))
  .orderBy(desc(orders.createdAt), asc(items.createdAt))
  .limit(500); // 50 orders × ~10 items avg

// Group in app code
const grouped = groupByOrder(rows);
-- Required index
CREATE INDEX CONCURRENTLY items_order_created_idx
  ON items (order_id, created_at);

The composite index satisfies both the join predicate and the secondary sort. Adding created_at lets the planner avoid a separate sort step.


Other Recommendations

Apply alongside the rewrite

Keep the `LIMIT 500` outer cap — large orders (>50 line items) are rare; truncate and lazy-load if needed1
Add `EXPLAIN (ANALYZE, BUFFERS)` to the test suite for this handler — catch plan regressions in CI2
Consider `ARRAY_AGG` on the server side if grouping in app code is hot in profiles3
Run `ANALYZE items;` after the index lands so the planner has fresh statistics4

Follow-ups

Watch list

The current orders_user_created_idx is fine, but only because users is sharded by tenant. If you ever consolidate tenants on a single Postgres, expect this index to bloat — plan to add tenant_id to the leading position before that migration.

Other N+1 candidates in this handler

order.shipments and order.payments are loaded in the same handler with the same pattern. The same JOIN-and-group fix applies. Recommend extracting a single fetchOrdersWithRelations helper that fans out three left joins behind a single round-trip.


Heuristic analysis from static source + table-size context. Confirm with EXPLAIN (ANALYZE, BUFFERS) on a representative dataset before promoting the rewrite.

This sample illustrates the skill's output format. Names, metrics, and operational details are illustrative unless the artifact explicitly analyzes public information.

View full sample →

All sales final. No refunds on digital products.

Includes support for Claude Code, Codex, OpenClaw, and Google Antigravity in the same license.

Also in Database Reliability

Bundle price: $55. Compare this skill with the full workflow bundle or Pro access.

Best for

Full-stack engineers debugging a p95 latency regression they suspect is database-bound, platform teams enforcing a query-budget on critical endpoints, and tech leads doing pre-merge review on data-access code in AI-assisted PRs. Most useful when the slow query is identifiable from logs and the table sizes are large enough that the wrong plan actually hurts.

Not ideal for

Tuning OLAP and analytics workloads (Snowflake, Redshift, BigQuery) where the cost model and optimizer behavior differ from row-store OLTP and the skill’s heuristics don’t map. Also a poor fit when the bottleneck is connection-pool exhaustion or replication lag rather than query plans — different problem, different tool.

Included in this purchase

  • Claude Code, Codex, OpenClaw, and Google Antigravity skill files.
  • Setup guidance for the right adapter in your workspace.
  • One-time license for the purchased skill version.

Setup

Plan for a short setup in the repository or workspace where the skill will run. Some coding familiarity helps for implementation-heavy outputs.

Claude CodeCodexOpenClawGoogle Antigravity

Related Skills

Incident Response
Outage Response Playbook
Generates structured, role-clear incident response playbooks for specific failure scenarios. Covers detection through resolution and post-mortem — ready to use when an incident actually happens.
Claude CodeCodexOpenClawGoogle Antigravity
outage-responsereliabilityrunbooks

$19.99

One-time license

View Skill
Incident Response
Incident Postmortem Writer
Generates a structured blameless postmortem from incident timelines, alerts, and deploy logs with root cause analysis, impact assessment, and owned action items. Useful for producing first-draft postmortems under operational pressure.
Claude CodeCodexOpenClawGoogle Antigravity
postmortemsincident-responseoperations

$19.99

One-time license

View Skill
Security Scanning
OWASP Top 10 Scanner
Scans code for OWASP Top 10 vulnerability patterns including injection, XSS, IDOR, and insecure deserialization with severity ratings and remediation snippets. Useful for pre-commit security checks and enterprise compliance.
Claude CodeCodexOpenClawGoogle Antigravity
securityowaspvulnerabilities

$19.99

One-time license

View Skill

Future Updates

This purchase includes the current version of the skill. If you want future adapter updates — meaning compatibility and packaging updates as supported platforms evolve — plus new catalog additions included automatically, upgrade to Pro.

Upgrade to Pro