djankies/claude-configs/optimizing-query-performance

Claude Code and agent skill by djankies/claude-configs

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Optimize queries with indexes, batching, and efficient Prisma operations for production performance.

Install

npx vskill@latest install djankies/claude-configs/optimizing-query-performance

SKILL.md

The same SKILL.md was published earlier as majiayu000/claude-skill-registry-data/optimizing-query-performance.

<overview> Query optimization requires strategic indexing, efficient batching, and monitoring to prevent common production anti-patterns.

Key capabilities: Strategic index placement (@@index, @@unique) · Efficient batch operations (createMany, transactions) · Query analysis & N+1 prevention · Field selection optimization & cursor pagination </overview>

<workflow> Phase 1 — Identify: Enable query logging; analyze patterns/execution times; identify missing indexes, N+1 problems, or inefficient batching

Phase 2 — Optimize: Add indexes for filtered/sorted fields; replace loops with batch operations; select only needed fields; use cursor pagination for large datasets

Phase 3 — Validate: Measure execution time before/after; verify index usage with EXPLAIN ANALYZE; monitor connection pool under load </workflow>

Quick Reference

Index Strategy:

ScenarioIndex TypeExample
Single field filter@@index([field])@@index([status])
Multiple field filter@@index([field1, field2])@@index([userId, status])
Sort + filter@@index([filterField, sortField])@@index([status, createdAt])

Batch Operations:

OperationSlow (Loop)Fast (Batch)
Insertfor...await create()createMany()
Updatefor...await update()updateMany()
Deletefor...await delete()deleteMany()

Performance Gains: Indexes (10-100x) · Batch ops (50-100x for 1000+ records) · Cursor pagination (constant vs O(n))

<constraints> MUST: Add indexes for WHERE/ORDER BY/FK fields with frequent queries; use createMany for 100+ records; cursor pagination for deep pagination; select only needed fields; monitor query duration in production

SHOULD: Test indexes with production data; chunk 100k+ batches into smaller sizes; use @@index([field1, field2]) for multi-field filters; remove unused indexes

NEVER: Add indexes without performance measurement; offset pagination beyond page 100 on large tables; fetch all

fields when only needing few; loop with individual creates/updates; ignore slow query warnings </constraints>

<validation> Measure Performance:

typescript
const start = Date.now()
const result = await prisma.user.findMany({ ... })
console.log(`Query took ${Date.now() - start}ms`)

Expected: 50-90% improvement for indexed queries, 50-100x for batch operations

Verify Index Usage: Run EXPLAIN ANALYZE; confirm "Index Scan" vs "Seq Scan"

Monitor Production: Track P95/P99 latency; expect reduced slow query frequency

Check Write Performance: Writes may increase 10-30% per index if rarely-used; consider removal </validation>

References

  • Index Strategy: references/index-strategy.md — indexing patterns and trade-offs
  • Batch Operations: references/batch-operations.md — bulk operations and chunking
  • Query Monitoring: references/query-monitoring.md — logging setup and slow query analysis
  • Field Selection: references/field-selection.md — select vs include patterns and N+1 prevention
  • Optimization Examples: references/optimization-examples.md — real-world improvements
  • Next.js Integration: Next.js plugin for App Router-specific patterns
  • Serverless: CLIENT-serverless-config skill for connection pooling

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/djankies/claude-configs/optimizing-query-performance/badge)](https://verified-skill.com/skills/djankies/claude-configs/optimizing-query-performance)

Something wrong with this skill or its page? Tell us.