Turbine ORM
The performance-first TypeScript Postgres ORM. Prisma-compatible API,
2-3x faster nested queries, zero runtime overhead beyond pg.
1 Query, Not N+1
Nested relations resolve in a single SQL query using Postgres json_agg. No client-side stitching.
Proven Fast
2.6x faster than Drizzle, 4.2x faster than Prisma on nested queries at p50. Real benchmarks, not marketing.
Zero Overhead
Only dependency is pg. No Rust binary, no WASM blob, no query engine process. Thin client, fast cold starts.
Quick Example
import { turbine } from './generated/turbine';
const db = turbine({ connectionString: process.env.DATABASE_URL });
// Nested relations in a single query -- no N+1
const users = await db.users.findMany({
where: { orgId: 1 },
with: {
posts: {
with: { comments: true },
orderBy: { createdAt: 'desc' },
limit: 5,
},
},
});
// users[0].posts[0].comments -- fully typed, single SQL round-trip
What Turbine generates: a single SQL statement with json_agg subqueries that returns the entire nested object graph in one database round-trip. Prisma would send 3 separate queries for this. Drizzle uses LATERAL joins which are competitive, but Turbine still wins on median latency.
Benchmark Highlights
Production results from Vercel Serverless hitting Neon Postgres:
| Scenario | Turbine | Drizzle | Prisma | |---|---|---|---| | L3 nested (median) | 5.3ms | 6.5ms | 7.4ms | | L2 nested (median) | 6.5ms | 9.1ms | 10.2ms | | Simple select | 5.6ms | 7.1ms | 3.9ms |
Local Docker results (50K iterations):
| Scenario | Turbine | Drizzle | Prisma | |---|---|---|---| | L2 nested p50 | 201us | 523us | 835us | | L2 nested RPS (c=50) | 24,041 | 6,360 | 3,784 | | Memory usage | 109MB | 117MB | 233MB |
View full benchmarks →
Key Features
- Nested Relations --
withclause resolves relations usingjson_agg, not N+1 queries - Pipeline API -- batch multiple independent queries into a single database round-trip
- Batch Inserts --
createManyusesUNNESTfor constant-parameter inserts at any batch size - Transactions --
$transaction()with typed table accessors, nested SAVEPOINTs, isolation levels - Middleware -- intercept all queries for logging, soft-deletes, timing, audit trails
- Schema Builder -- define schemas in TypeScript with
defineSchema(), push withturbine push - Migrations -- create, apply, rollback SQL migrations with
turbine migrate - Raw SQL -- tagged template literals with parameterized queries and type safety
- Type-safe -- generated client from your database schema with full IDE autocompletion
- CLI --
init,generate,push,migrate,seed,statuscommands
Get Started
# 1. Install
npm install turbine-orm
# 2. Initialize project
npx turbine init --url postgres://user:pass@localhost:5432/mydb
# 3. Generate typed client from your database
npx turbine generate
Full quick start guide →