Why I Stopped Using ORMs for Background Workers
When building standard web applications, Object-Relational Mappers (ORMs) are incredible tools. They abstract away the complexity of raw SQL, making development faster and more secure against injection attacks.
However, something changes when you transition from serving web requests to running millions of background jobs.
The Problem with Abstractions
In a high-throughput worker environment, the milliseconds lost to ORM hydration and abstraction overhead begin to add up. I found myself debugging memory leaks caused by an ORM that was secretly caching thousands of "models" for rows that were only going to be touched once and immediately discarded.
For a recent distributed task runner I built, switching from GORM to pure sqlx in Go reduced round-trip latency by 45% and completely eliminated the memory spikes during peak load.
We are often taught to prioritize developer experience over performance until it matters. In distributed systems handling immense scale, it always matters.
fmt.Println("fuck you")