ts-db-perf

Optimize TypeScript database code by removing N+1 queries and adding pagination.

4|Updated Feb 13, 2026
One-click install
npx skills add https://github.com/widnyana/eyay-toolkits --skill ts-db-perf
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ts-db-perf
Source: https://github.com/widnyana/eyay-toolkits/tree/main/plugins/ts-backend-dev/skills/ts-db-perf
Command: npx skills add https://github.com/widnyana/eyay-toolkits --skill ts-db-perf

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It fixes slow TypeScript backend database access by removing inefficient query patterns and preventing correctness issues like race conditions and flaky retries.

Core Features & Use Cases

  • Eliminate N+1 queries by rewriting loops into joins/includes or batched IN/JOIN strategies, so list endpoints don’t explode into hundreds of round-trips.
  • Improve performance-critical queries by selecting only needed fields, adding pagination, and tightening async execution with parallel reads where safe.
  • Harden writes and concurrency using transactions, chunked batch updates, optimistic locking/atomic updates, and idempotency to prevent double-processing.

Quick Start

Optimize the attached TypeScript database code to remove N+1 queries, add safe pagination and caching where appropriate, and prevent race conditions or non-atomic updates.

Frequently Asked Questions about ts-db-perf

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix N+1 queries in TypeScript backend database code?

Fix N+1 queries in TypeScript by rewriting loops into joins, includes, or batched IN/JOIN strategies. This prevents list endpoints from triggering hundreds of individual database round-trips, drastically improving response times.

What is the best way to prevent race conditions in TypeScript database transactions?

Prevent race conditions in TypeScript database transactions by using atomic updates, optimistic locking, and idempotent retry handling. These mechanisms ensure safe concurrency and prevent double-processing during read-then-write flows.

How do I optimize slow TypeScript list endpoints with pagination and caching?

Optimize slow TypeScript list endpoints by selecting only needed fields, implementing safe pagination strategies, and adding caching with proper invalidation. Tightening async execution with parallel reads also improves performance.

Does this database optimization approach work with raw SQL and ORM usage in TypeScript?

Yes, this database optimization approach works with both ORM and raw SQL usage in TypeScript. It targets inefficient async patterns and query structures regardless of the database interaction method you use.

Why are my TypeScript database queries slow and how can I improve selectivity?

TypeScript database queries are often slow due to poor selectivity and inefficient async patterns. Improve them by selecting only necessary fields, adding pagination, and executing parallel reads where safe to reduce latency.

How do I handle idempotent retries for chunked batch updates in TypeScript?

Handle idempotent retries for chunked batch updates in TypeScript by wrapping writes in transactions and using atomic operations. This prevents double-processing and ensures data consistency during concurrent database access.