I use an ORM (nHibernate) in an application that requirerequires high performancesperformance and handlehandles billions of records. With time we noticed that most significant performance problems wherewere related to our own way to useof using the ORM rather than due to the ORM alone.
The ORM should not replace your mandatory database knowledge. It's a tool you use to get more productivity and flexibility in your code, but you'll need to know underlying processes to optimize your performancesperformance.
You did not specify a specific ORM so here are the things we did to improve performancesperformance:
- We used an ORM profiler. (we used nhprof)
- We used a database profiler. (we used SQL Server Profiler)
- We read as many articles as we can on the subject. (Many were available for nHibernate in addition to the entire chapter on the subject in the documentation)
- We bought specific books on performance & scalability.
- We created benchmarking system to test our own optimisations.
- and more importantly, we were able to test our code with real life customers with huge data. That last thing alone helped us spot most problems in our application.