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.
One-Time Purchase
$19.99
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
| Finding | Current | Target |
|---|---|---|
| Round-trips | 51 | 1 |
| p95 latency | 38s | ~280ms |
| Access path | Seq Scan | Composite 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
After
Single JOIN with composite index
One query, Index Scan on items
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
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.
Related Skills
$19.99
One-time license
$19.99
One-time license
$19.99
One-time license
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.