4

I am trying to understand which ORM is fast in performance?

  • NHibernate support Level 2 caching can we compare its performance with EF or Dapper?
  • EF Code First looks promising, but do we have inbuilt Level 2 cache support for EF?
  • Don't know much about Dapper ORM

Can someone please explains me pros and cons of this ORM and which one to choose for application performance boost.

Igor Popov
  • 9,795
  • 7
  • 55
  • 68
Jordon Willis
  • 4,851
  • 7
  • 27
  • 34
  • 1
    There are probably some comparisons online (*elsewhere*). This "question" is not well-suited for SO. –  Sep 12 '12 at 02:15
  • 2
    @pst Man... If you know the source, post it here, it doesn't make sense that w/o any reason you decide what is suitable and what is not... – Jordon Willis Sep 12 '12 at 02:25
  • 1
    http://stackoverflow.com/faq <-- but that does. "practical, *answerable* questions based on *actual problems* that you face" –  Sep 12 '12 at 02:29
  • 3
    @pst problem with people like you is you behaves like mother-in-law in .net community... If you know answer post it here, if you don't know let other answers... If you feel that you know everything and don't want to answer that's fine, but let us try to understand... I hate .net grandma – Jordon Willis Sep 12 '12 at 02:33
  • 1
    The problem is I feel *there is no suitable answer within the scope of SO*. Which is why I voted to close it. The question is too broad as it stands. –  Sep 12 '12 at 02:34
  • Also, possible duplicates [this post](http://stackoverflow.com/questions/18132/ado-net-entity-vs-nhibernate) and [this post](http://stackoverflow.com/questions/1377236/nhibernate-entity-framework-active-records-or-linq2sql) – Mark Oreta Sep 12 '12 at 02:37

1 Answers1

31

The problem with "big" ORM tools such as EF or NHibernate, is that (exagerating?) 99% of developers are overwhelmed with mastering simply how to make it work; they don't have time to figure out how to make it perform. Worse, making these tools perform properly usually boils down to having competent SQL/Database design and tuning skills - which weakens a major selling point of the ORM.

The issue with Level 2 caching, in my opinion, is eclipsed by the other performance losses a poorly-used ORM introduces. It seems most projects using an ORM are doing a poor job of it (along with a poor job of designing the database), which makes level 2 caching somewhat moot.

As a consequence, micro-ORM tools like Massive or Dapper (the latter is used by Stack Overflow) are very attractive:

  • Unlike a macro ORM, developers don't spend months learning how to use them. Each micro-ORM is less than a thousand lines of code (criminy!). How long could that possibly take to understand?
  • The extra time developers have on their hands can be dedicated to gaining more mastery of SQL, which they will need to learn for a performant use of a macro or micro ORM.

To be clear, a well-used macro ORM is a great thing. Do you have the highly experienced staff to ensure that it is well-used?

The bottom line is this: if you think a full-scale ORM will safely hide database complexity, almost assuredly you'll be mistaken. If I'm given a choice I would go with a micro ORM. Don't get me wrong, I think EF and NHIbernate are very cool and I'm jazzed to use them - I'm just saying you need to manage your expectations.

Brent Arias
  • 29,277
  • 40
  • 133
  • 234
  • 4
    I really disagree that it takes a lot of effort to make NHibernate perform. The 1st level cache (session) alone can give great performance benefits, and that's without any extra configuration. And with Fluent NHibernate or the new mapping code in NHibernate it's a lot easier to get start with it. Your comment about poor use of an ORM and poor database design will hold just the same for anything that people use - most developers will not go look at the source code for a project whether it's 1000 lines or 100 000 lines... – Martin Ernst Sep 12 '12 at 07:49
  • 13
    Your answer boils down to "I don't really know much about ORMs, but I have a strong opinion about them anyway". 99.9% of the developers are overwhelmed? really? Or just you? – Diego Mijelshon Sep 12 '12 at 12:30
  • 12
    I agree with him on severals points. I am using Entity Framework right now and i feel like i don't know well enough how it work to feel confident there won't be any problems later... as he said.. we don'T have time to see how it should perform. – Rushino Mar 14 '13 at 23:38
  • 2
    The answer makes a good point imo. Speaking purely for EF, the vast majority of projects I've seen have lost huge amounts of time getting the thing to work. When the recommended solution is finally identified (i.e. nulling relationship objects), it's difficult to believe. – FBryant87 Jul 26 '17 at 10:26
  • 3
    I use Dapper even in production environments. It works perfectly. Very Less complicated and also very fast! – vibs2006 Mar 16 '18 at 06:52