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 ?
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;
}
}