Profiling my application I've discovered an unpleasant fact what typed Upadte<> (and Query<>) builder evaluates lambda expressions on each request, consuming a lot of CPU. You will gain several percents of CPU, switching from nice and modern typed UpdateBuilder<> as:
var u = Update<MyPerson>.Inc(e => e.Age, Age);
to old good static strings:
var u = Update.Inc("Age", Age);
The same problem with QueryBuilder<>, it's also evaluates expressions on each request and wastes valuable CPU resources for nothing.
The official LINQ driver's page states:
The C# compiler translates all queries written using query syntax into lambda syntax internally anyway, so there is no performance advantage or penalty to choosing either style.
Yes, it's true if you choose between two LINQ syntaxes. But there is a huge performance difference between using and not using LINQ syntax. Overhead depends on how often your client performing queries. In my case, it's above 30% difference!
Is there any way to get the nice typed syntax and performance both together, I wonder?
Simple caching of builder results is not an answer as far as we obviously need to pass dynamic params to each request. We need to find the way to "pre-compile" CPU-expensive part (concerning lambda expressions evaluation) but preserve dynamic params (ex. array indexes).