Reputation: 81
We are trying to use nHibernate first time in my project in VS2010 and Oracle.
Performance of the application is key criteria for acceptance of this project, should we use nHibernate in this project?
We are going through POC. we have a table with 250 columns and when trying to insert 500 records, application goes dead.
Can some one suggest about performance comparison of nHibernate vs. PL/SQL CRUD.
Not aware what parameter should we use in nHibernate configuration file to get optimum performance?
We are using following configuration
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory name="DefaultSessionFactory">
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
<property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
<property name="??;</property>
<property name="show_sql">true</property>
<property name="use_proxy_validator">false</property>
</session-factory>
</hibernate-configuration>
Thanks in anticipation.
Upvotes: 1
Views: 1575
Reputation: 18796
I know you accepted an answer already, but wanted to throw my 2c in anyway.
First of all, you day in one of your comments:
The application would have more than 300 columns
Thats obsurb. If what you're doing is reporting, don't use an ORM, if it's not reporting, then I would say your database is very poorly designed, there's no reason to have 300 columns. I don't know Oracle, but in SQL Server you would take a performance hit from columns being on separate pages to the row when you reach over 8k in row length.
The queries generated would be massive. You're better off using Stored Procedures and not using an ORM.
but i was trying with 4 columns entity and it was taking 30 seconds to insert 100 rows and the same insertion was taking 2-3 seconds with normal pl/sql insert queries
There's many reasons why this might occur. If you're generating the identity in the database, then NHibernate has to throw in another select to retrieve the Id to apply to the Model that was just inserted.
Letting NHibernate generate the identity can speed things up, either via HiLo or Guid/GuidComb.
Opening a brand new session for each insert can be costly when added up also, re-use the same session for the inserts, and batch the inserts together rather than sending off single statements. (again I don't know if Oracle supports batching like SQL Server)
Either way, you provided no code to show your test to give anyone an indication of why it was slow for you. NH performs really well for 99% of peoples needs.
Upvotes: 0
Reputation: 1759
the suggestiongs about show_sql and logging have an impact, but even with those on, you shouldn't have problems of the application grinding to its knees just because of nhibernate. sure, there's some performance penalty in using orm in return for all the goodness it provides in terms of maintainability and the ability to create your application quickly, but in most cases it is not enough to matter.
if you are having performance problems that are that serious, i'd suggest there is something in your application causing that. it's not just nhibernate and using something else would make it better (unless you are doing something different with that something else). the first thing that comes to mind is that you should know what isolation level the transactions in your system are using. depending on how you are managing sessions and transacactions, you might be using a higher isolation level than you need and unecessarily locking database entities. this could lead to what you describe and also deadlocks. the default isolation level for system.tranactions is serializable, which is big time locking and probably not what you want. you can set the default for nhibernate generated transactions with:
<add key="hibernate.connection.isolation" value="ReadCommitted" />
if you are using system.transactions (transactionscope), you can specify the isolation level in the constructor. if you are using wcf, there are attributes and configuration and other ways of managing this. without knowing more about your application, it's hard to say much more, and this is really just a guess as to whether this is your problem or not.
Upvotes: 1
Reputation: 49261
Iridium's suggestion to turn off show_sql is a good one. If you're using log4net, you should make sure that you set the logging level for NHibernate. If you have the level set to DEBUG application wide, NHibernate will log a large number of entries.
<logger name="NHibernate">
<level value="ERROR" />
</logger>
Upvotes: 1