Building a High-Performance ORM in Go: Lessons from Flash ORM
How we built an ORM that outperforms Prisma and Drizzle by 3-12x — architecture decisions, SQLC integration, and the tradeoffs we made.
Why We Built Flash ORM
Most Go developers reach for GORM, but GORM has a well-known performance problem: it uses reflection heavily, which adds overhead on every query. We wanted something that felt like Prisma (schema-first, type-safe) but ran at Go's native speed.
The Architecture
Flash ORM is built on top of SQLC — a tool that generates type-safe Go code from raw SQL. Instead of building a runtime query builder, we generate code at schema-definition time. This means zero reflection at runtime.
// Define your schema
model User {
id Int @id @default(autoincrement())
email String @unique
name String
}
// Flash generates this for you
func (q *Queries) GetUser(ctx context.Context, id int32) (User, error) {
return q.db.QueryRowContext(ctx, getUser, id).Scan(...)
}
Benchmark Results
We ran benchmarks against Prisma (Node.js) and Drizzle on identical hardware with PostgreSQL:
| Operation | Flash ORM | Drizzle | Prisma |
|---|---|---|---|
| Single read | 0.8ms | 4.2ms | 9.6ms |
| Bulk insert (1000) | 12ms | 48ms | 97ms |
| Complex join | 2.1ms | 8.7ms | 19ms |
The 3-12x improvement comes from two things: no reflection, and connection pooling baked in by default.
Safe Migrations
One thing we're proud of is transaction-based migrations. Every migration runs inside a transaction — if any step fails, the entire migration rolls back. No more half-applied schema changes in production.
flash migrate up // applies pending migrations
flash migrate down // rolls back last migration
flash migrate status // shows current state
Flash Studio
We also built a visual database manager (Flash Studio) that lets you browse tables, run queries, and export data in JSON, CSV, or SQLite format — all from a local web UI that spins up with flash studio.
What's Next
Multi-database transactions across PostgreSQL and MySQL, and a VS Code extension for schema autocomplete. The project is open source at github.com/Lumos-Labs-HQ/flash — contributions welcome.