Uploaded image for project: 'NHibernate [Moved to GitHub]'
  1. NH-3207

Poor performance loading data due to IDataReader.GetOrdinal

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not an Issue
    • Affects versions: 3.3.0.GA
    • Fix versions: None
    • Components: Core
    • Labels:
      None
    • Sprint:

      Description

      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 2.112.1.0 with 11g
      NET 4.0

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                gpersson Greg Persson
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Who's Looking?