nhibernate-core
nhibernate-core copied to clipboard
Allow to customize partial expression evaluation for optimization purpose
Currently, NHibernate/ReLinq queryable implementation relies on expression compilation to partially evaluate expressions. As previously noted in #2947, this is quite costly when used on hot paths. We also observe this in a highly loaded web application performing a lot of NHibernate queries.
We also use ReLinq directly for another subset of queries (with our own queryable provider instead of NHibernate), and we were able to significantly reduce CPU usage, JIT, and GC pressure by plugging in a custom evaluator which does not involve expression compilation at all.
I'd like to do the same for NHibernate in our project. Unfortunately, NhLinqExpression calls NhRelinqQueryParser.PreTransform directly, and currently there is no way to customize partial evaluation. Some related work was done in #2411, but that custom pre-transformer is invoked after partial evaluation, so it does not help in this case.
If you think such extension point would suit the design of NHibernate, I can look into creating a pull request.