ActiveRecord: biting the hand that feeds you

BY Doug Breaker

October 09, 2017

Richard Schneeman (better known as Schneems) recently wrote about how he reduced his database server load by 80%...with one simple trick. In the Hacker News discussion that followed, much of the debate was on the merits of using an ORM like ActiveRecord...or not:


In every case I can think of, writing raw SQL is likely to execute queries faster than using ActiveRecord. So, why don't I just write raw conn.exec('SELECT * FROM users') everywhere?

Performance is an important thing, but it's not THE most important thing. In Richard's case, he had a 20 minute blip where response times were significantly higher for his app (a side project, btw):


Some points:

In our jobs as developers - and in life - our biggest challenge is choosing how to best spend our time. I'm not against raw SQL, but I rely on tools to tell me when I need to drop down to that level.

PS - our database monitoring is in early access. This would have gotten to the problem query quicker, I believe :).