Object Relational Mappers or ORMs are a layer of software that sits between web developers and the database backend. For instance if you’re using Ruby as your web development language, you’ll interact with MySQL through an ORM layer called ActiveRecord. If you’re using Java, you may be fond of the ORM called Hibernate.
ORMs have been controversial because they expose two very different perspectives to software development. On the one hand we have developers who are tasked with building applications, fulfilling business requirements, and satisfying functional requirements in a finite amount of time. On the other hand we have operations teams which are tasked with managing resources, supporting applications, and maintaining uptime and availability.
Often these goals are opposing. As many in the devops movement have pointed out, these teams don’t always work together keeping common goals in mind. How does this play into the discussion of ORMs?
Relational databases are a technology developed in the 70’s that use an arcane language called SQL to move data in and out of them. Advocates of ORMs would argue rightly so, that SQL is cumbersome and difficult to write, and that having a layer of software which helps you in this task is a great benefit. To be sure it definitely helps the development effort, as software designers, architects and coders can focus more of their efforts on functional requirements and less on arcane minutiae of SQL.
Problems come when you bump up against scalability challenges. The operations team is often tasked with supporting performance requirements. Although this can often mean providing sufficient servers, disk, memory & cpu resources to support an application, it also means tuning the application. Adding hardware can bring you 2x or 5x improvement. Tuning an application can bring 10x or 100x improvement. Inevitably this involves query tuning.
That’s where ORMs become problematic, as they don’t promote tweaking of queries. They are a layer or buffer to keep query writing out of sight.
In our experience as performance and scalability experts for the past fifteen years, query tuning is the single biggest thing you can do to improve your web application. Furthermore some of the most challenging and troublesome applications we’ve been asked to tune have been built on top of ORMs like Hibernate.