Back to list
djankies

optimizing-query-performance

by djankies

0🍴 0📅 Nov 25, 2025

SKILL.md


name: optimizing-query-performance description: Optimize queries with indexes, batching, and efficient Prisma operations for production performance. allowed-tools: Read, Write, Edit, Bash version: 1.0.0

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

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

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))

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

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

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

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon