Daniel

Alternative Query Builder for Prisma ORM - Boost up read operations to raw SQL speed

by
Is Prisma slow? Speed up slow Prisma reads by 2–7× without refactors. Bypass Prisma’s read execution path with direct SQL execution in PostgreSQL and SQLite (up to 53.5× on SQLite relation filters). Production-ready optimization for read-heavy Prisma workloads.

Add a comment

Replies

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

const sql = postgres(process.env.DATABASE_URL)

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

// Use Prisma exactly as before - it's just faster now
const users = await prisma.user.findMany({
  where: { status: 'ACTIVE' },
  include: { posts: true },
})


That's all it takes to make it work