Query: Prevent client evaluation when using certain result operators in complex query
See original GitHub issueSteps to reproduce
await
db.ProxyServerLoadResult.AsNoTracking()
.Include(x => x.ProxyServer)
.Where(x => !x.ProxyServer.BlockedByOperator)
.Where(x => x.SourceId == 1)
.OrderByDescending(x => x.Score)
.Take(100)
.Select(x => x.ProxyServer)
.ToListAsync();
The issue
I guess this warning is wrong. Am I right?
Exception message:
Warning as error exception for warning 'RelationalEventId.QueryClientEvaluationWarning': The LINQ expression 'join ProxyServer x.ProxyServer in value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[RP.DataModel.ProxyServer]) on Property([x], "ProxyServerId") equals Property([x.ProxyServer], "ProxyServerId")' could not be translated and will be evaluated locally. To suppress this Exception use the DbContextOptionsBuilder.ConfigureWarnings API. ConfigureWarnings can be used when overriding the DbContext.OnConfiguring method or using AddDbContext on the application service provider.
Further technical details
EF Core version: 1.1.0 Operating system: Windows 10 Visual Studio version: VS2015U3
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Complex Query Operators - EF Core
This page describes some of the complex operators and their supported variations.
Read more >Query optimization techniques in SQL Server: tips and tricks
In this blog post we will show you step by step some tips and tricks for successful Query optimization techniques in SQL Server....
Read more >Chapter 4. Query Performance Optimization
In the previous chapter, we explained how to optimize a schema, which is one of the necessary conditions for high performance. But working...
Read more >SQL Query Optimization: 12 Useful Performance Tuning ...
In the article, we are going to examine how to optimize SQL queries and improve query performance by using SQL query optimization tips...
Read more >Optimize query computation | BigQuery
Best practices to optimize query performance. ... Query specific columns. ... use SELECT * EXCEPT to exclude one or more columns from the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@AsValeO as a workaround try putting Take(100) at the end of the query like so:
this produces a much simpler query from the EF perspective, that we are able to fully translate at the moment. If possible, you should always try to put Skip/Take/Distinct as the last operation when using EF Core (at least until we address the current limitations).
The reason is that those are what we call ResultOperators - they are always the last operation in a given query. If there are more operations following, we introduce subqueries, which complicates the translation significantly for some cases. E.g. the original intermediate model representation for your original query is:
and the proposed workaround:
@maumar I think I’ve encountered this issue also. When you say fixed, do you mean this will be included in the Entity Framework Core 2.0 release?
EDIT: I see it was included in preview 1 https://github.com/aspnet/EntityFramework/releases/tag/rel%2F2.0.0-preview1