Resolution: Not an Issue
Affects Version/s: 3.3.0.GA
Fix Version/s: None
The issue I’m facing was reported about 4 years ago @ https://forum.hibernate.org/viewtopic.php?f=25&t=989865
The problem is that NHibernate.Type.Nullable.NullSafeGet(IDataReader rs, string names, ISessionImplementor session, object owner) uses IDataReader.GetOrdinal for every single value in the ResultSet.
The MSDN page for GetOrdinal http://msdn.microsoft.com/en-us/library/system.data.idatarecord.getordinal.aspx states
“Because ordinal-based lookups are more efficient than named lookups, it is inefficient to call GetOrdinal within a loop. Save time by calling GetOrdinal one time and assigning the results to an integer variable for use within the loop.”
This problem does not manifest itself using the SqlDataProvider because it implements a caching mechanism to eliminate this problem. However, I’m using ODP.NET and its implementation of GetOrdinal is naïve and performs very slowly.
For a record set with 40 columns and 4000 rows, it takes about 3.7 seconds to Hydrate the nHibernate objects. The same database call using DataSets and DataAdapters takes about 0.3 seconds. This is because the DataAdapter does not use GetOrdinal at all.
ADO.NET Provider: ODP.NET 188.8.131.52 with 11g