Home >

My Thoughts on ORM comparisons

22. August 2009

I am a bit late to the party but there we go.

Last several days, there have been a hot debate on the performance and capability of NH vs some other commercial/noncommercial ORMs. This issue has been discussed both in NHibernate Developer List and in Ayende’s blog. I have recently noticed another benchmark between NH and EF, which I hope to address, too.

Fallacies of benchmark

What I have seen in those benchmarks is the wrong use of ORMs. This statement has two aspects: Wrong use of ORM and wrong use of NH itself.

In ORM, you don’t use it to do bulk operations. And 0.001 second difference will not differ anything in your application. If it does, you don’t also use RDBMS, you use something else.

There is no point on making a loop of thousands of iterations which saves an entity. Davy has well pointed out that this has a lot of implications in NHibernate, unlike some other ORMs. First of all, NHibernate first-level cache will be in action and it will fill the cache with each item saved. Secondly, as NH makes use of POCO it has no mechanism of things like INotifyPropertyChanged, it has to compare the old to the new value. As you may guess, the more entity you have, the longer it will take. No exception. If you want to leave first-level cache out of the game, you use StatelessSession feature of NHibernate, no exception. Actually when you check Fabio Maulo’s post you’ll see it can even become faster without Stateless Session.

Another point I have noticed in both benchmarks is that they are/were not fair. If I compare it to EF, lets say, ctx.SaveChanges() will batch the chages and send the query to the database in one go. NH has this feature, as Ayende already pointed out, since 2006. However, NH by default doesn’t make use of it, and this is not a bug, it is a feature. You have to use setting to enable it.

Benchmark the community, too

NHibernate has a big community, and great minds as committers. It really does matter. Let me give you some statistics about NHibernate development and its community

Here is the commit statistics.

image 

It is one of the most active projects in .net environment. The image above doesn’t include the contrib projects. A great kiss goes  to Fabio Maulo for his massive efforts.

Let’s look at discussion group, shall we?

image

Do you know any other group with that activity? I don’t know.

 

In addition, NHibernate gives you more than _ANY_ ORM can give. It gives you a lot of extensibility points which can be used in a lot of scenario. Validator, Search, Spatial, Shards to name a few.

In conclusion

NHibernate is the obvious winner.

Comments

8/23/2009 4:55:53 AM #
Pingback from topsy.com

Twitter Trackbacks for
        
        My Thoughts on ORM comparisons - Tuna Toksoz's weblog
        [tunatoksoz.com]
        on Topsy.com
3/21/2011 10:49:34 PM #
I can't say that I agree with the article completely but I have still learned something from this piece.  Keep informing us.
3/21/2011 10:53:24 PM #
What can I say.  This article is pretty good compared to all the junk out there that I have seen.  
3/21/2011 10:59:10 PM #
I can't say that I agree with the article completely but I have still learned something from this piece.  Keep informing us.
3/21/2011 11:09:04 PM #
This article seems to be well crafted. I wish more people would ake some time and write quality articles that are much needed like this one. Thanks
3/21/2011 11:24:25 PM #
What a great opportunity to finally read something worth reading.  thanks a lot and keep posting articles like this for us to read.
3/21/2011 11:34:43 PM #
This article seems to be well crafted. I wish more people would ake some time and write quality articles that are much needed like this one. Thanks
3/21/2011 11:34:43 PM #
I just want to say that your blog is very nice.  Please keep writing informative articles like this.
3/21/2011 11:39:24 PM #
What a great opportunity to finally read something worth reading.  thanks a lot and keep posting articles like this for us to read.
3/22/2011 6:51:53 PM #
I just want to say that your blog is very nice.  Please keep writing informative articles like this.
3/22/2011 7:04:10 PM #
I just want to say that your blog is very nice.  Please keep writing informative articles like this.
3/22/2011 7:06:56 PM #
Great article! So happy to finally see a decent post about tis topic.  I will bookmark it so that I may come back and read more.
3/22/2011 7:14:00 PM #
This article is good but I disagree with some certain points in it. Oh well, I am not a complete expert on the matter.  Thanks for the article anyways.
3/22/2011 7:18:29 PM #
I see there is some very good information in this article. Please continue with the work that you are doing
3/22/2011 7:25:08 PM #
Great article! So happy to finally see a decent post about tis topic.  I will bookmark it so that I may come back and read more.
3/22/2011 7:37:02 PM #
I see there is some very good information in this article. Please continue with the work that you are doing
3/22/2011 7:53:35 PM #
I have been searching all over the internet for something to give me the correct advice.  This is not exactly what I was looking for but it helped a lot.  Thanks
3/22/2011 8:04:34 PM #
I just want to say that your blog is very nice.  Please keep writing informative articles like this.
3/22/2011 8:04:35 PM #
What can I say.  This article is pretty good compared to all the junk out there that I have seen.  
3/22/2011 8:09:46 PM #
This article is good but I disagree with some certain points in it. Oh well, I am not a complete expert on the matter.  Thanks for the article anyways.
3/23/2011 5:27:59 AM #
Hello, I have been reading and enjoying your articles for some time now.  I appreciate your outlook on things.  I'm finally going to bookmark your page so I can keep coming back.  I repeatedly stumble upon it and keep thinking it's awesome but never saving it.  See you next time!  Keep posting us with these great writings!
3/23/2011 10:56:31 AM #
The new Zune browser is surprisingly good, but not as good as the iPod's. It works well, but isn't as fast as Safari, and has a clunkier interface. If you occasionally plan on using the web browser that's not an issue, but if you're planning to browse the web alot from your PMP then the iPod's larger screen and better browser may be important.
3/23/2011 12:11:22 PM #
Hands down, Apple's app store wins by a mile. It's a huge selection of all sorts of apps vs a rather sad selection of a handful for Zune. Microsoft has plans, especially in the  realm of games, but I'm not sure I'd want to bet on the future if this aspect is important to you. The iPod is a much better choice in that case.
3/23/2011 2:04:29 PM #
Hands down, Apple's app store wins by a mile. It's a huge selection of all sorts of apps vs a rather sad selection of a handful for Zune. Microsoft has plans, especially in the  realm of games, but I'm not sure I'd want to bet on the future if this aspect is important to you. The iPod is a much better choice in that case.
Comments are closed