All posts
databasebackend

Drizzle, Two Years Later: Now the Default in Every Backend I Start

Drizzle is close to 1.0 and Prisma dropped Rust, so speed isn't the argument anymore. The reason I still start every Node backend with Drizzle is simpler. It's SQL, with types.

Muhamad Choirul Adam 6 min readPhoto: Unsplash

Two years ago I wrote about reaching for Drizzle instead of Prisma. The argument then was mostly about speed: fewer layers, no code generation step, no Rust engine binary, so smaller bundles and faster cold starts on serverless.

That argument got weaker. Prisma fixed most of it. And yet Drizzle has gone from "worth trying" to the default in every Node.js backend I start, whether it's Hono, Express, or a plain script. This post is about why.

The short version: it's typed SQL

I think in SQL. When I picture a query, I picture SELECT ... FROM ... JOIN ... WHERE. Drizzle lets me write exactly that, and TypeScript checks every column name and every type along the way.

Here's a query in SQL:

SELECT o.id, o.total, p.name AS partner
FROM orders o
INNER JOIN partners p ON p.id = o.partner_id
WHERE o.status = 'paid' AND o.total > 100000
ORDER BY o.created_at DESC
LIMIT 20;

And here it is in Drizzle:

const rows = await db
  .select({ id: orders.id, total: orders.total, partner: partners.name })
  .from(orders)
  .innerJoin(partners, eq(partners.id, orders.partnerId))
  .where(and(eq(orders.status, "paid"), gt(orders.total, 100_000)))
  .orderBy(desc(orders.createdAt))
  .limit(20);

Same shape, line for line. If I rename a column in the schema, this stops compiling. If I compare total to a string, it stops compiling. And rows is typed as { id: string; total: number; partner: string }[] without me writing that type anywhere.

That's the whole pitch. No new query language to learn, no guessing what SQL an engine will generate. The SQL I'd write by hand, with a compiler watching.

What a new backend looks like for me now

Every Node project starts with the same three files.

The schema, in TypeScript:

db/schema.ts
import { integer, pgTable, text, timestamp } from "drizzle-orm/pg-core";
 
export const partners = pgTable("partners", {
  id: text("id").primaryKey(),
  name: text("name").notNull(),
});
 
export const orders = pgTable("orders", {
  id: text("id").primaryKey(),
  partnerId: text("partner_id")
    .notNull()
    .references(() => partners.id),
  status: text("status", { enum: ["pending", "paid", "refunded"] }).notNull(),
  total: integer("total").notNull(),
  createdAt: timestamp("created_at").defaultNow().notNull(),
});
 
export type Order = typeof orders.$inferSelect;
export type NewOrder = typeof orders.$inferInsert;

The client, one module the whole app imports:

db/index.ts
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
 
const client = postgres(process.env.DATABASE_URL!);
export const db = drizzle({ client });

The routes. With Hono and a Zod validator, the request body and the database row are both typed end to end:

routes/orders.ts
import { zValidator } from "@hono/zod-validator";
import { Hono } from "hono";
import { z } from "zod";
import { db } from "../db";
import { orders } from "../db/schema";
 
export const ordersRoute = new Hono().post(
  "/",
  zValidator("json", z.object({ partnerId: z.string(), total: z.number().int().positive() })),
  async (c) => {
    const input = c.req.valid("json");
    const [order] = await db
      .insert(orders)
      .values({ id: crypto.randomUUID(), status: "pending", ...input })
      .returning();
    return c.json(order, 201);
  },
);

Nothing in that route is Hono-specific except the routing. db is just a module. In Express, the handler body is identical:

app.post("/orders", async (req, res) => {
  const input = orderInput.parse(req.body);
  const [order] = await db
    .insert(orders)
    .values({ id: crypto.randomUUID(), status: "pending", ...input })
    .returning();
  res.status(201).json(order);
});

That portability is underrated. I switch frameworks between projects. The data layer comes with me unchanged.

The things I use every week

Transactions look like what they are:

await db.transaction(async (tx) => {
  await tx.update(orders).set({ status: "refunded" }).where(eq(orders.id, id));
  await tx.insert(refunds).values({ orderId: id, amount });
});

Raw SQL when I need it, without leaving type safety completely:

const [{ revenue }] = await db
  .select({ revenue: sql<number>`coalesce(sum(${orders.total}), 0)` })
  .from(orders)
  .where(eq(orders.status, "paid"));

The sql template escapes values for you and still lets you reference typed columns. Window functions, CTEs, Postgres-specific operators: when the query builder doesn't have a method for it, you're never stuck.

Migrations as plain SQL. drizzle-kit generate diffs the schema and writes a .sql file I can read in review. drizzle-kit migrate applies it. No hidden state.

What changed in two years

Rendering diagram…

Drizzle is close to 1.0, not there yet. The release candidates started in April, rc.5 landed in October, and the latest stable line is still 0.45. For new projects I use the RC. For production apps on 0.x, I'm waiting for final 1.0. The 1.0 cycle includes deliberate breaking changes, like how column casing is configured, so it's a real migration, not a version bump.

Relational queries got rewritten. For nested data, the new API takes plain objects instead of helper functions:

const partner = await db.query.partners.findFirst({
  where: { id: partnerId },
  with: { orders: { where: { status: "paid" }, orderBy: { createdAt: "desc" }, limit: 5 } },
});

It still compiles to one SQL statement. I use it for read-heavy screens with nested data, and the SQL-style builder for everything else.

Prisma dropped Rust. Prisma 7, released in November 2025, replaced its Rust query engine with a query compiler in TypeScript and WebAssembly. Prisma says the engine shrank from about 14 MB to about 1.6 MB and queries got faster. That fixes most of what I complained about in 2024.

Rendering diagram…

So is Drizzle still faster?

At runtime, it's still the thinner layer: build a SQL string, call the driver, done. On tight memory budgets like Cloudflare Workers, that still counts. But the gap is much smaller than it was, and I haven't found a neutral benchmark of Prisma 7 against Drizzle on identical queries. Most numbers come from one of the two teams. Prisma's own comparison, for example, shows its types checking about 1.5x faster than Drizzle's in the editor, a different kind of speed that might matter more to a big codebase.

Honestly, your indexes will decide your query times far more than your ORM.

Why it's still my default

Speed got me to try Drizzle. It's not why I stayed. I stayed because:

  • I can read every query and know the exact SQL it runs.
  • The compiler catches renamed columns, wrong types, and typos before I run anything.
  • The schema is just TypeScript, so types update the moment I save. No generate step.
  • It goes wherever my code goes: Hono, Express, a cron script, a serverless function.

If you think in models and want the ORM to handle the SQL, Prisma is a good tool and better than it's ever been. If you think in SQL and want types on top of it, that's what Drizzle is. Two years in, I don't start a backend without it.