🚀 The Solution for Slow Prisma

Fix Slow Prisma Queries
Make Your API 2–7× Faster (Up to 53.5×)

Is Prisma slow? You're not alone. Love Prisma's DX but need better performance? Speed up slow Prisma queries by 2–7× (up to 53.5× on SQLite relation filters) without changing any existing queries.

Faster Prisma Reads
No Query Changes
Production-Ready
137 E2E Tests
Fix slow Prisma in one line
import { PrismaClient, Prisma } from '@prisma/client'
import { speedExtension, convertDMMFToModels } from 'prisma-sql'
import postgres from 'postgres'

const sql = postgres(process.env.DATABASE_URL)
const models = convertDMMFToModels(Prisma.dmmf.datamodel)

const prisma = new PrismaClient().$extends(
  speedExtension({ postgres: sql, models })
)

const users = await prisma.user.findMany({
  where: { status: 'ACTIVE' },
  include: { posts: true }
})
2–7×
Faster Prisma Reads
Typical speedup
0
Query Changes
Keep your existing Prisma calls
137
E2E Tests
Verified solution
100%
Type Safety
Same Prisma API

Why Is Prisma Slow?

Understanding Prisma's evolution and performance characteristics helps explain why this extension exists.

The Prisma Journey: DX First, Performance Matters at Scale

🎯 2019: The Birth of Modern Prisma

Prisma 2 launched in 2019, changing the TypeScript ORM landscape with type-safe database access and generated types from your schema. Prisma introduced an engine-based architecture to translate queries, validate them, and provide strong guarantees that were hard to achieve with traditional JavaScript ORMs.

⚡ 2020–2022: Rapid Growth & Feature Expansion

Prisma added powerful features like nested writes, transactions, and middleware. The feature set expanded, but every query still paid an architectural cost: queries are represented, validated, executed, and results are shaped to match the Prisma API.

📊 2023: Overhead Becomes Noticeable at Scale

As more teams deployed Prisma in high-traffic workloads, the fixed per-query overhead became measurable. This is most visible on read-heavy endpoints, analytics, aggregations, and large result sets. The overhead is not a bug; it's the cost of Prisma’s guarantees and API behavior.

🚀 2024–2025: Prisma Performance Work Continues

Prisma shipped major updates focused on performance and engine changes. Even with improvements, there is still an unavoidable cost to parsing, validating, planning, and shaping results compared to executing raw SQL directly.

🎯 2026: prisma-sql Extension Released

This extension focuses on read performance. It bypasses Prisma’s read execution path for findMany, findFirst, findUnique, count, aggregate, and groupBy, while keeping Prisma for writes, migrations, schema management, and type generation. Validate compatibility with your Prisma version before rollout.

💡 Why This Extension Exists

Prisma made the right architectural choices for its goals: type safety, developer experience, and cross-database behavior. But those choices create overhead that's noticeable at scale. This extension doesn't replace Prisma—it optimizes reads for teams that want Prisma's DX plus faster execution where it matters.

Query Translation Layer

Prisma translates your query inputs into database-specific SQL. This enables cross-database behavior and Prisma's API semantics, but adds processing time before the database sees the SQL.

Validation & Type Guarantees

Prisma validates queries against the schema and enforces API-level guarantees. These safeguards prevent classes of bugs, but they also add overhead to each query.

Result Shaping

Results are shaped to match Prisma's API behavior. This is great for DX and consistency, but it adds latency, especially on large result sets and complex includes.

This extension complements Prisma by offering a faster path for read queries. You keep everything you love about Prisma while getting 2–7× faster reads in typical cases (and up to 53.5× in SQLite relation filters) when performance matters.

How Much Faster? Real Benchmarks

Comprehensive comparison across Prisma v6, v7, Drizzle ORM, and Prisma-SQL

Benchmark environment: MacBook Pro M1 • PostgreSQL 15 • SQLite 3.43 • 137 test cases per database

PostgreSQL

Average across 57 test cases

Prisma v6
2.10ms
Prisma v7
1.95ms
1.08× faster
Drizzle ORM
1.40ms
1.50× faster
Prisma-SQL ⚡
0.90ms
2.34× faster
6.3×
Distinct Queries
vs Prisma v6
5.5×
Relation Filters
vs Prisma v6 (none)

SQLite

Average across 56 test cases

Prisma v6
5.48ms
Prisma v7
4.12ms
1.33× faster
Drizzle ORM
2.11ms
2.60× faster
Prisma-SQL ⚡
0.73ms
7.50× faster
12.6×
Simple Queries
vs Prisma v6
69.7×
Relation Filters
vs Prisma v6 (none)

Benchmarks based on 137 E2E tests per database. Prisma v6.16.3, Prisma v7.2.0, Drizzle ORM latest. View complete benchmark data →

Detailed Benchmark Results

Statistical comparison with Welch's t-test and a 1ms practical significance threshold

These results reflect runtime mode, where queries are converted to SQL on each request. In prerendered mode, SQL is generated at build time — runtime executes raw parameterized queries with zero conversion overhead.

PostgreSQL Prisma v6

Avg 1.99x vs Prisma Avg 1.27x vs Drizzle 25/95 significant wins 70 within noise floor
Jun 7, 2026
Test Prisma prisma-sql Drizzle Speedup Sig. CV% n
findMany basic 0.602ms ±0.020 0.481ms ±0.257 0.357ms ~1.00x 192.7% 50
findMany where = 0.563ms ±0.015 0.373ms ±0.051 0.456ms ~1.00x 49.5% 50
findMany where >= 17.20ms ±0.509 4.82ms ±0.358 6.80ms 3.57x 1.41x D *** 26.8% 50
findMany where IN 0.614ms ±0.024 0.417ms ±0.031 0.426ms ~1.00x 27.0% 50
findMany where null 0.292ms ±0.019 0.158ms ±0.042 0.175ms ~1.00x 96.9% 50
findMany ILIKE 0.324ms ±0.054 0.271ms ±0.0097 0.295ms ~1.00x 12.8% 50
findMany AND 3.06ms ±0.169 1.00ms ±0.088 2.64ms 3.06x 2.63x D *** 31.9% 50
findMany OR 14.91ms ±0.409 3.98ms ±0.306 5.57ms 3.75x 1.40x D *** 27.7% 50
findMany NOT 0.614ms ±0.031 0.369ms ±0.023 0.408ms ~1.00x 22.4% 50
findMany orderBy 3.41ms ±0.074 1.28ms ±0.067 1.35ms 2.67x 1.05x D *** 18.8% 50
findMany pagination 0.323ms ±0.027 0.233ms ±0.026 0.242ms ~1.00x 39.5% 50
findMany select 0.289ms ±0.018 0.168ms ±0.041 0.199ms ~1.00x 87.7% 50
findMany relation some 1.24ms ±0.072 0.843ms ±0.069 ~1.00x 29.7% 50
findMany relation every 0.717ms ±0.017 0.619ms ±0.062 ~1.00x 36.0% 50
findMany relation none 31.99ms ±0.908 6.99ms ±0.368 4.58x *** 19.0% 50
findMany nested relation 0.740ms ±0.023 0.959ms ±0.139 ~1.00x 52.5% 50
findMany complex 1.19ms ±0.027 0.514ms ±0.013 0.721ms ~1.00x 8.9% 50
findFirst 0.239ms ±0.016 0.221ms ±0.025 0.209ms ~1.00x 40.3% 50
findFirst skip 0.291ms ±0.014 0.167ms ±0.0069 0.209ms ~1.00x 15.2% 50
findUnique id 0.222ms ±0.015 0.163ms ±0.029 0.136ms ~1.00x 63.8% 50
findUnique email 0.196ms ±0.011 0.114ms ±0.017 0.140ms ~1.00x 52.8% 50
count 0.127ms ±0.026 0.053ms ±0.0019 0.063ms ~1.00x 13.9% 50
count where 0.473ms ±0.016 0.271ms ±0.0067 0.297ms ~1.00x 9.0% 50
aggregate count 0.224ms ±0.014 0.164ms ±0.0097 ~1.00x 21.2% 50
aggregate sum/avg 0.326ms ±0.010 0.255ms ±0.0089 ~1.00x 12.6% 50
aggregate where 0.486ms ±0.023 0.284ms ±0.0080 ~1.00x 10.3% 50
aggregate min/max 0.322ms ±0.0091 0.254ms ±0.0089 ~1.00x 12.6% 50
aggregate complete 0.419ms ±0.011 0.304ms ±0.011 ~1.00x 12.7% 50
groupBy 0.433ms ±0.013 0.359ms ±0.011 ~1.00x 11.1% 50
groupBy count 0.498ms ±0.021 0.412ms ±0.018 ~1.00x 15.8% 50
groupBy multi 0.601ms ±0.012 0.460ms ±0.011 ~1.00x 8.2% 50
groupBy having 0.560ms ±0.012 0.516ms ±0.028 ~1.00x 19.5% 50
groupBy + where 0.559ms ±0.012 0.384ms ±0.016 ~1.00x 14.6% 50
_count via include 0.712ms ±0.027 0.698ms ±0.024 ~1.00x 12.1% 50
_count via include + relations 1.68ms ±0.041 1.69ms ±0.119 ~1.00x 25.5% 50
groupBy aggregates 0.669ms ±0.080 0.452ms ±0.017 ~1.00x 13.2% 50
groupBy min/max 0.595ms ±0.045 0.485ms ±0.053 ~1.00x 39.7% 50
include list + nested to-one 1.76ms ±0.116 0.448ms ±0.033 3.92x *** 26.6% 50
include list + nullable to-one 2.66ms ±0.040 1.83ms ±0.271 ~1.00x 53.3% 50
include posts 5.30ms ±1.31 2.13ms ±0.142 5.45ms 2.49x 2.56x D *** 24.1% 50
include profile 0.794ms ±0.088 0.472ms ±0.046 0.580ms ~1.00x 35.0% 50
include 3 levels 2.56ms ±0.333 1.63ms ±0.142 1.63ms ~1.00x 31.4% 50
include 4 levels 2.33ms ±0.102 1.07ms ±0.028 1.50ms 2.17x 1.40x D *** 9.5% 50
include + where 1.34ms ±0.038 0.796ms ±0.034 1.85ms ~1.00x 15.2% 50
include + select nested 1.51ms ±0.076 1.73ms ±0.131 1.76ms ~1.00x 27.3% 50
findMany startsWith 0.251ms ±0.020 0.178ms ±0.019 0.192ms ~1.00x 39.4% 50
findMany endsWith 0.745ms ±0.115 0.274ms ±0.039 0.356ms ~1.00x 52.0% 50
findMany NOT contains 1.00ms ±0.305 0.283ms ±0.040 0.370ms ~1.00x 50.3% 50
findMany LIKE 0.301ms ±0.079 0.170ms ±0.014 0.211ms ~1.00x 30.3% 50
findMany < 29.00ms ±0.735 6.89ms ±0.323 10.36ms 4.21x 1.50x D *** 16.9% 50
findMany <= 35.14ms ±3.06 6.75ms ±0.312 11.66ms 5.21x 1.73x D *** 16.7% 50
findMany > 16.68ms ±0.469 4.30ms ±0.211 6.95ms 3.88x 1.62x D *** 17.8% 50
findMany NOT IN 0.628ms ±0.031 0.489ms ±0.123 0.431ms ~1.00x 90.9% 50
findMany isNot null 0.621ms ±0.015 0.213ms ±0.0086 0.333ms ~1.00x 14.5% 50
orderBy multi-field 3.10ms ±0.119 0.936ms ±0.093 0.777ms 3.32x 0.83x D *** 35.9% 50
orderBy relation to-one 2.06ms ±0.047 1.52ms ±0.039 ~1.00x 9.3% 50
orderBy relation + scalar 2.14ms ±0.049 1.55ms ±0.063 ~1.00x 14.7% 50
orderBy nullable relation 1.86ms ±0.034 1.19ms ±0.032 ~1.00x 9.9% 50
orderBy deep relation 3.12ms ±0.292 1.70ms ±0.037 1.83x *** 7.9% 50
orderBy deep relation + scalar 3.85ms ±0.423 2.68ms ±0.262 1.44x *** 35.2% 50
distinct status 10.83ms ±0.417 1.27ms ±0.041 8.56x *** 11.8% 50
distinct multi 17.93ms ±2.05 2.72ms ±0.125 6.59x *** 16.6% 50
cursor composite tuple 1.77ms ±0.052 1.31ms ±0.039 ~1.00x 10.6% 50
cursor composite desc 1.95ms ±0.065 1.82ms ±0.159 ~1.00x 31.4% 50
cursor prefix of orderBy 1.80ms ±0.058 1.31ms ±0.043 ~1.00x 11.8% 50
select + include 1.16ms ±0.070 0.766ms ±0.132 0.375ms ~1.00x 62.4% 50
_count relation 0.844ms ±0.034 0.671ms ±0.044 ~1.00x 23.9% 50
_count multi-relation 0.256ms ±0.013 0.174ms ±0.0097 ~1.00x 20.2% 50
_count inside include 1.32ms ±0.033 1.25ms ±0.051 ~1.00x 14.7% 50
_count inside nested select 2.25ms ±0.043 2.00ms ±0.078 ~1.00x 14.0% 50
_count deep include 2.05ms ±0.046 1.45ms ±0.077 ~1.00x 19.2% 50
ILIKE special chars 0.283ms ±0.015 0.224ms ±0.018 ~1.00x 28.6% 50
LIKE case sensitive 0.262ms ±0.028 0.190ms ±0.018 ~1.00x 34.6% 50
findMany Date range 0.404ms ±0.025 0.534ms ±0.019 0.603ms ~1.00x 13.0% 50
count Date range 0.524ms ±0.030 0.411ms ±0.019 0.451ms ~1.00x 16.8% 50
findMany Date gte 0.413ms ±0.027 0.208ms ±0.0086 0.276ms ~1.00x 14.7% 50
depth-1 low-fan 0.445ms ±0.017 0.265ms ±0.023 ~1.00x 31.4% 50
depth-1 mid-fan 2.76ms ±0.092 2.08ms ±0.080 ~1.00x 13.9% 50
depth-1 high-fan 2.38ms ±0.072 1.96ms ±0.059 ~1.00x 10.8% 50
depth-1 wide 2.22ms ±0.044 1.41ms ±0.044 ~1.00x 11.2% 50
depth-1 unbound 43.88ms ±0.708 10.39ms ±0.320 4.22x *** 11.1% 50
depth-2 5.04ms ±0.290 2.91ms ±0.177 1.73x *** 22.0% 50
depth-2 paginated Project→tasks 1.78ms ±0.188 1.87ms ±0.183 ~1.00x 35.4% 50
depth-2 high-fan 2.85ms ±0.113 1.30ms ±0.083 2.19x *** 22.9% 50
depth-2 wide 5.02ms ±0.246 1.94ms ±0.061 2.58x *** 11.3% 50
depth-2 unbound 66.25ms ±1.47 14.93ms ±0.817 4.44x *** 8.8% 10
depth-3 unbound 18.86ms ±4.30 5.90ms ±0.303 3.19x *** 18.5% 50
depth-3 paginated 2.07ms ±0.150 1.40ms ±0.104 ~1.00x 26.9% 50
depth-4 unbound 10.24ms ±0.442 4.34ms ±0.168 2.36x *** 14.0% 50
depth-4 paginated 2.46ms ±0.193 1.79ms ±0.249 ~1.00x 50.2% 50
findFirst depth-2 2.23ms ±0.079 1.71ms ±0.071 ~1.00x 15.0% 50
findUnique depth-2 Project→tasks→comment 2.37ms ±0.202 2.05ms ±0.135 ~1.00x 23.8% 50
complex nested select 3.56ms ±0.170 3.49ms ±0.440 ~1.00x 45.5% 50
ultra deep query 15.31ms ±0.248 6.71ms ±0.310 2.28x *** 16.7% 50
transaction: (3 operations) 2.79ms ±0.059 1.36ms ±0.025 2.05x *** 6.5% 50
*** p < 0.001 ** p < 0.01 *  p < 0.05 ns not significant  within 1ms noise floor ± 95% CI CV% > 15% = high variance
Runtime mode benchmarked. Prerendered mode skips query-to-SQL conversion entirely at runtime — expect lower latency than shown here, especially for complex queries where conversion cost is proportionally higher.

How It Optimizes Prisma

Bypass Prisma's read execution path while keeping Prisma's API and types

1

Intercept Prisma Queries

Extension catches read operations (findMany, findFirst, findUnique, count, aggregate, groupBy) before they execute

2

Generate Optimized SQL

Convert Prisma queries into fast, parameterized SQL with optimized JOINs

3

Execute Directly

Run queries through postgres.js or better-sqlite3, bypassing Prisma read overhead

4

Return Compatible Results

Results match Prisma's expected shape. Types, IntelliSense, and existing query code remain unchanged

const users = await prisma.user.findMany({
  where: { status: 'ACTIVE' },
  include: { posts: true }
})

// Direct SQL execution for reads
// Benchmarked around ~1.00ms on this workload
// Same Prisma query code

Why Choose This Prisma Extension?

Get raw SQL execution speed for reads while keeping Prisma's developer experience

Instant Prisma Speedup

One-time setup accelerates Prisma reads. No refactoring, no migration, no downtime.

Keep Your Prisma Types

Full TypeScript support maintained. Type inference, autocomplete, and compile-time safety preserved while accelerating reads.

Production-Tested Solution

137 E2E tests validate compatibility with recent Prisma versions. Used to accelerate Prisma reads in production apps.

Multiple Database Support

Optimize Prisma reads on PostgreSQL (including Neon, Supabase) and SQLite.

Pre-Compiled Option

Optional generator creates build-time SQL, reducing overhead to microseconds for your hottest queries.

Serverless Ready (Node Runtimes)

Works in serverless Node runtimes. Edge runtime support depends on runtime constraints and the driver you use.

When Prisma Performance Matters Most

Common scenarios where this extension makes a real difference

📊 Analytics & Reporting

Prisma aggregations and groupBy operations benefit significantly from direct SQL execution

  • 5× faster groupBy accelerates reports
  • Faster aggregate queries
  • Real-time metrics with lower latency

🚀 High-Traffic APIs

Per-query overhead compounds under load, especially on read-heavy endpoints

  • Lower API response times
  • Handle more requests per instance
  • Reduce infrastructure costs

☁️ Serverless Functions

Every millisecond matters in serverless: reduce read latency where it counts

  • Better p95/p99 on reads
  • Lower costs through faster reads
  • Faster reads without refactors

📱 Mobile Backends

Users notice latency: faster reads improve perceived UX immediately

  • Faster feed loading
  • Faster pagination
  • More responsive interactions

Optimize Prisma in 3 Steps

Accelerate Prisma reads in under 60 seconds

① Install the Prisma Extension

# PostgreSQL
npm install prisma-sql postgres

# SQLite
npm install prisma-sql better-sqlite3

② Add Extension to Prisma Client

import { PrismaClient, Prisma } from '@prisma/client'
import { speedExtension, convertDMMFToModels } from 'prisma-sql'
import postgres from 'postgres'

const sql = postgres(process.env.DATABASE_URL)
const models = convertDMMFToModels(Prisma.dmmf.datamodel)

const prisma = new PrismaClient().$extends(
  speedExtension({ postgres: sql, models })
)

③ Use Prisma Normally

const users = await prisma.user.findMany({
  where: { status: 'ACTIVE' },
  include: { posts: true }
})

Prisma Performance FAQ

Common questions about optimizing Prisma reads

Why does Prisma have overhead?

Prisma adds overhead because it implements API guarantees like schema-based validation, consistent query behavior, and result shaping. Those layers provide a great developer experience but cost time compared to executing raw SQL directly.

How do I optimize Prisma queries?

Optimize read-heavy Prisma workloads by adding this extension. It executes read operations via direct SQL using postgres.js or better-sqlite3 while keeping Prisma's API and types. Setup is a small initialization change and does not require refactoring your existing queries.

Is Prisma slower than raw SQL?

For many read workloads, yes. There is architectural overhead compared to raw SQL execution. This extension aims to keep Prisma's DX while reducing read latency by executing SQL directly.

Can I speed up Prisma without changing existing queries?

Yes. Add the extension once during Prisma Client initialization and keep your existing Prisma query code unchanged. Read operations run faster while your Prisma API, types, and schema remain the same.

Does this work in production?

Yes. It is validated with 137 E2E tests and designed to be used in production. Always verify compatibility with your Prisma version and run your own regression tests before rollout.

What causes slower Prisma aggregations?

Aggregations and groupBy often amplify fixed overhead (query processing and result shaping) and can involve larger intermediate result sets. This extension optimizes those reads by generating SQL directly, which typically reduces latency on aggregation-heavy endpoints.

Ready to Speed Up Prisma?

Join developers optimizing Prisma reads: 2–7× faster (up to 53.5×)