kashifpbutt wrote:
Hi,
I am new to this. I have a simple question. Would NHibernate be recommended over SQL/ADO.NET where the number of records can exceed well over 10 million? Please provide some documentation or reference that I can look up as well.
Thank you for your time.
Kashif Pervaiz Butt
Hi Kashif,
The difference between using NHibernate vs. traditional SQL/ADO.Net isn't really a question about performance, but about different architectural decisions and for some people personal preference.
Martin Fowler's Patterns of Application Architecture describes both of these patterns:
Domain Model http://martinfowler.com/eaaCatalog/domainModel.html - supported by persistence frameworks such as NHibernate
Table Module http://martinfowler.com/eaaCatalog/tableModule.html - supported by ADO.Net in the .Net space.
Regardless which method you choose, you will have issues dealing with 10 million + records.
People who typically grew up in the Microsoft space favor the Table Module pattern since most of the the tools provided by Microsoft were more data-centric.
The majority of people who grew up in the Java space tend to favor the domain model because there are a number of tools available to them that support it.
I've used both the Domain Model and persistence frameworks (TopLink for Java and NHibernate) and ADO.Net very successfully.
My preference is to use the Domain Model with persistence frameworks as I prefer to focus on the behavior of the system instead of the data.
I have found that working with ADO.net and the table module architecture, a larger percentage of development time is spent on managing the database queries/stored procedures and/or whatever method you are using to interact with the database.
Take the example of adding a new column to a table.
SQL/ADO.Net
You would need to change the select, insert, update queries and/or stored procedures, plus the strongly typed data set and the table ddl using.
NHibernate
you would update your object that is persisted, the table ddl and your mapping file.
Adding a new persistence object is also much faster using the domain model and a persistence framework as is refactoring existing persistent objects.
Using a Domain Model with persistence frameworks also means that the developer can spend more time in the language of choice instead of having to switch between SQL and vb.Net/c#.net.
I am an ex-dba and have found that using persistence frameworks you can achieve very good database performance with very large sets of data as effectively as you can using SQL/ADO.Net without giving up too much control to the persistence framework.
I have also found that NHibernate does an excellent job of generating SQL that performs well under a large volume of data.
This is my humble opinion...
-Greg