Why We Switched from Prisma to Drizzle — Type-Safe SQL Without the ORM Tax
Drizzle's SQL-like API eliminated Prisma's query plan surprises, cut bundle size 60%, and made complex joins explicit — but the migration cost 2 weeks and we lost Prisma's visual schema browser.
Published 2026-06-17
Why We Switched from Prisma to Drizzle — Type-Safe SQL Without the ORM Tax
TL;DR: Prisma’s hidden N+1 queries, 2.3MB client bundle, and opaque query plans cost us 3 production incidents in 6 months. Drizzle 0.33 gave us explicit SQL, 900KB bundle, and zero surprises — but migration took 2 weeks and we lost prisma studio for non-technical stakeholders. Full comparison →
The Context
Three-dev team, Next.js 14 + PostgreSQL (Supabase) + tRPC. Prisma 5.x since Jan 2025. Pain points: (1) N+1 in include: { posts: { include: { author: true }}} on dashboard — 47 queries for 20 users, 2.1s response. (2) prisma migrate deploy timeout on 500k-row table (lock contention). (3) Bundle analysis: Prisma Client 2.3MB gzipped (18% of client bundle). (4) Type-safe but query-unsafe — runtime surprises.
What We Tested
| Tool | Use Case | Verdict | Why |
|---|---|---|---|
| Drizzle ORM 0.33 | Full repo migration (8 models, 47 relations) | ✅ | Explicit joins, 900KB bundle, query plan visible in code, zero N+1 since |
| Prisma 5.18 (latest) | Same queries, optimized with select | ⚠️ | Can fix N+1 but requires deep query plan knowledge; bundle unchanged |
| Kysely | Type-safe SQL builder alternative | ✅ | Closer to raw SQL, excellent types, but no migration tool (use golang-migrate) |
| Prisma + ZenStack | Auth/RLS layer on top | ⚠️ | Adds complexity; still Prisma underneath |
The Pivot Point
March 2026: Dashboard API p99 2.1s. EXPLAIN ANALYZE showed 47 queries from single findMany with nested includes. Prisma’s query event logging confirmed N+1. Fix: hand-written SQL in $queryRaw — defeated Prisma’s purpose. April: prisma migrate deploy hung 18 min on 500k-row ActivityLog table (adding index). Supabase advisory lock contention. June: Decided to migrate. 2 weeks: drizzle-kit introspect:pg → generated schemas → rewrote 247 tRPC procedures → updated tests. Pain: prisma studio gone — product manager used it for quick data checks. Workaround: built admin panel with drizzle-orm + tanstack-table.
What We Use Now
Drizzle ORM 0.33 as primary database layer:
- Schema:
db/schema/*.ts— single source of truth, TypeScript types inferred - Queries:
db.select().from(users).innerJoin(posts, eq(users.id, posts.authorId)).where(...)— explicit, readable, no surprises - Migrations:
drizzle-kit generate:pg→drizzle-kit migrate:pg— SQL files indrizzle/, reviewable in PR - Bundle: 900KB gzipped (was 2.3MB) — 60% reduction
- CI:
pnpm drizzle-kit checkvalidates schema against Supabase staging
Drizzle Studio (experimental) for internal data browsing:
- Runs
npx drizzle-kit studio— local only, no auth, not for stakeholders - Replaced PM’s
prisma studiouse with custom admin panel (Next.js + TanStack Table + Drizzle)
When You’d Choose Differently
- Prisma if: team includes non-SQL-fluent devs, need
prisma studiofor PM/ops, rely on Prisma’s middleware/extensions (soft deletes, multi-tenancy), or have massive existing Prisma codebase where migration ROI is negative. - Kysely if: you want raw SQL control with TypeScript types, don’t need a migration tool (bring your own), and prefer query builder over ORM patterns.
- Raw pg + Zod if: maximum performance, minimal deps, team writes SQL daily — but lose type-safe schema evolution.
Tool Crucible Rating
| Dimension | Rating (1–5) | Notes |
|---|---|---|
| Overall | 4 | Query predictability + bundle size win; migration cost + studio loss are real |
| Ease of Use | 3 | Learning curve: SQL knowledge required; drizzle-kit CLI is excellent |
| Value | 5 | Free, MIT, no runtime overhead, replaces Prisma’s $0 but with better DX |
| Support | 4 | Active Discord, weekly releases, Supabase/Neon/PlanetScale first-class |
This is part of our Database Tooling series. See full comparison: Drizzle vs Prisma vs Kysely: Type-Safe Database Access in 2026
Last reviewed 2026-06-17. See our methodology and affiliate policy.