Re: Performance issue: When using projections, metadata for a row is evaluated for each row even though it does not change.

52 views
Skip to first unread message

Ricardo Peres

unread,
May 24, 2013, 7:52:45 AM5/24/13
to nhu...@googlegroups.com
Nice work! I think it would be important to register this on JIRA.

Go to https://nhibernate.jira.com/login?dest-url=%2Fsecure%2FDashboard.jspa an choose "Create an account".

RP

On Monday, May 6, 2013 1:26:04 PM UTC+1, Carsten Hess wrote:
In my example I read 12000 rows with 38 columns and transform the data to DTO's. With 3.3.3.4000 it takes around 4.5 seconds to do so.

By using ANTS profiler I have spottet that the majority of the time is spend getting the metadata for every row even though they are the same for every one of them. One place to short-circuit this is in CriteriaQueryTranslator - the 2 properties ProjectedTypes and ProjectedColumnAliases - but it could also be made further down the callstacks . 

I made my own patch of 3.3.x (caching the 2 forementioned properties) and my query then runs in under 1 sec. More than 80% saving. All NHibernate test are green.


My question is - would the team accept the change or how do I go about it ?

I have tried logging in at https://nhibernate.jira.com/secure/Dashboard.jspa but simply can't figure out how to get a login!

Best regards
Carsten



The change is as I said just to cache the properties in CriteriaQueryTranslator:


   private IType[] _cachedProjectedTypes;
   private string[] _cachedProjectedColumnAliases;


public IType[] ProjectedTypes
{
get
{
   if (_cachedProjectedTypes != null) return _cachedProjectedTypes;

                _cachedProjectedTypes = rootCriteria.Projection.GetTypes(rootCriteria, this);
   return _cachedProjectedTypes;
}
}

public string[] ProjectedColumnAliases
{
get
{
   if (_cachedProjectedColumnAliases != null) return _cachedProjectedColumnAliases;

                _cachedProjectedColumnAliases = rootCriteria.Projection is IEnhancedProjection
? ((IEnhancedProjection)rootCriteria.Projection).GetColumnAliases(0, rootCriteria, this)
: rootCriteria.Projection.GetColumnAliases(0);

   return _cachedProjectedColumnAliases;
}
}
 

Carsten Hess

unread,
Jun 20, 2013, 7:44:33 AM6/20/13
to nhu...@googlegroups.com
I have created this issue: https://nhibernate.jira.com/browse/NH-3486, and hope it will be accepted.

Best regards
Carsten
Reply all
Reply to author
Forward
0 new messages