-
-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue: Performance while working with EF core #153
Comments
Generating a dynamic class takes some time, but this should only be done once I hope. Can you create a full example project ? |
Hello, StefH. Thanks for the reply! And I'm sorry about the previous test result. 00:00:16.8311778 -> origin linq expression query 100_000 times And this is my git repository: Again, thanks for the help! |
I found the code which has the most performance impact, it's |
It's obvious that it will take more time. With dynamic linq you create an expression tree at runtime, wich is then used against the queryable. With your other example, the expression tree is created at compile time. But you can use ExpressionParser directly, and store the expression and then use the cached expression in the where. |
Hello, @jogibear9988 . I found
In this way, I can solve part of my problems, but my query parameter values are dynamic. That means, I may query Again, thank you! |
I don‘t think the cache should be in dynamic linq. If it is, how big it should be,... I won‘t like it. I think we should be able to return a Compiled Expression Tree, to wich you can hand over the paramters later. I‘ll look if this is possible. But don‘t know when I‘ve time! And maybe you still need to pass the first parameters, cause somtimes the type of the parameter is needed to create the tree! |
With some changes I get on my machine this performance:
|
New nuget will be uploaded. |
Recently, I want to use dynamic linq in my aspnet core web application, to dymaniclly build my query.
So I want to test the performance of dynamic linq while working with ef core.
In my test, I use EF core Inmemory database to store my data, then query the data by origin linq expression and dynamiclinq, and compare the time they cost.
Here is my codes:
As you can see, in my codes, I looped 1000 times to compare the query performance between origin linq expression and dynamic linq, and here is my console outputs:
00:00:01.2343062 -> origin linq expression query 1000 times
00:00:09.7961837 -> dynamic linq query 1000 times
It seems that dynamic linq is much more slower than origin linq expression while working with ef core.
Can anybody help me? Did I missed someting about dynamic linq?
Thank you.
The text was updated successfully, but these errors were encountered: