2012/3/19 Chinna <[email protected]>: > Hi All, > > I have been evaluating the performance of NHibernate and ADO.NET. I > have created a test application which has an Employee table with > 75,000 records. When I try to get data using NHibernate it is very > slow compare to ADO.NET, it’s about 290% (approx.) slower.
Or to put it another way: When I try to get data using ADO.NET it is very low in features compared to NHibernate. > > The average performance of NHibernate to bind 75,000 records is 2535 > milliseconds . > The average performance of ADO.net to bind 75,000 records is 867 > milliseconds. > > I can understand that NHibernate is a Wrapper to ADO.NET but you > cannot pay the price of 300% for retrieval Let's say I have a typical operation in my application which needs to load about 100 objects (which is more reasonable for NHibernate use case). With your timings the time to bind them would then go from 1.2 ms with ADO.Net to 3.6 ms with NHibernate. Given all the other features, that's 300% I'm willing to pay in many scenarios. I think the important point here is that describing NHibernate as a wrapper is the wrong point of view. NHibernate abstracts the data access in so many ways. It's sort of as describing a large truck as a "wrapper" for a motorcycle - both will get you there but of course the truck is likely to be much slower because it focus on other features: loading capacity over raw speed. You will have to figure out what is most important in your project. To be specific: bulk loading is not the main focus of NHibernate - if this is the main use case in your scenario then perhaps you may need to look for a different solution. If it's a limited part of your system but NHibernate adds a lot of value in other parts - design around the limitation for the specific usecase. That being said, if you can point to specific problem areas where performance can be improved with reasonable effort, I don't think anyone would mind. > Query Executed in SQL Manually : > Select ID, Name, DateOfJoin, DateOfBirth, DepartmentID, Status from > Employee : Duration 516 > > Query Executed in SQL by NHibernate : > Select this._ID as ID2_0_, this_.Name as Name2_0_, this_.DateOfJoin as > DateOfJoin2_0_, this_.DateOfBirth as DateOfBirth2_0_, > this_.DepartmentID as DepartmentID2_0_, this_.Status as Status2_0_ > from dbo.Employee this_: Duration 1538 > What is the time unit? How did you time this? Executed both in management studio? If the time unit is large enough to matter, I find it surprising (e.g. hard to believe) that the SQL query in itself will be three times slower because longer identifiers are used. Apart from all the other features with NHibernate, it uses reflection so you don't need to hard code loaders for each of your classes. Your test code for ADO.Net does not use reflection. What happens if you remove this difference? /Oskar -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
