docs/plans/agent-native/009-skill-performance.md
A prisma-performance skill in prisma/skills: a router for "my Prisma app is slow" with
references for investigation and for the specific improvements agents should know to suggest.
Agents are eager to optimize but reach for Prisma-6-era or generic-ORM advice; this skill
gives them the Prisma-7-correct playbook.
log: ['query'] with event listeners for durations), tracing via
@prisma/instrumentation, and sqlcommenter tags to attribute SQL to call sites.EXPLAIN (ANALYZE, BUFFERS) the hot queries; how to extract the exact SQL + params from
Prisma logs to feed it.where/orderBy fields to @@index / @unique additions in the schema; remind
that relation scalar fields (foreign keys) are not auto-indexed on PostgreSQL.endsWith / contains on string columns: these compile to infix/suffix LIKE, which
cannot use a btree index. Options ladder: PostgreSQL pg_trgm GIN index (via
postgresqlExtensions preview + raw DDL migration), generated/reversed columns for
endsWith, or full-text search via TypedSQL (task 007) — with "measure first" framing.relationJoins preview: database-level JOINs for nested reads instead of multiple queries;
when it helps (deep includes, high row counts) and when the default strategy wins._count, aggregate, groupBy)
instead of fetch-and-reduce; select narrow projections; orderBy + take instead of
sorting in JS; distinct caution — client-level distinct is applied in memory, use
nativeDistinct preview where supported. Worked before/after query pairs for each.@prisma/client-engine-runtime), so multi-query plans and in-memory joins/filters show up
as multiple SQL statements in the query log for one client call (in Prisma 6 the equivalent
work hid inside the native engine). Teach: one client call emitting several queries or
post-processing large row sets is the signal to restructure the query or enable
relationJoins.node:cluster, PM2, or container replicas — with pool sizing recalculated per process
(total connections = pool size × process count; cross-reference task 006's pooling
reference).