Uploaded image for project: 'NHibernate'
  1. NHibernate
  2. NH-2534

Join-fetching a many-to-one with property-ref results in select n+1 problem

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0.0.GA
    • Fix Version/s: None
    • Component/s: Core

      Description

      The attached test shows that a many-to-one association referencing an unique property (instead of the Id) results in a select n+1 problem. Although the first statement contains the correct join, all associated entities are fetched one by one after the join select. (Entities with the same value in the unique column are even fetched more than once.)

      The interesting point is that this bug only occurs if the referenced entities are already in the session cache. If they are not, no additional select statements are created.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              cremor cremor
            • Votes:
              13 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:

                Who's Looking?