-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
SqlServer Error 8623 The query processor ran out of internal resources and could not produce a query plan #11006
Comments
SQL Server is limited to 2100 parameters https://docs.microsoft.com/en-us/sql/sql-server/maximum-capacity-specifications-for-sql-server |
Hi @ErikEJ Can EF Core split the queries every 2100 parameters? |
Not currently, but you could! |
@ErikEJ - It does not look like query has any closure variable which would be parametrized. It should be fully converted to SQL without any parameters. |
@smitpatel unfortunately i couldn't trace the query with sql server profiler, aparently it is too big, too many parameters. What is funny is that i could do the same query logic by doing a select without any where's and filtering in memory my poco list. |
@xaviergxf - Can you share the linq query then? I am not able to see how the query in first post could generate a large SQL |
@smitpatel i cannot post the linq query. The query does a left join as well, that is perhaps the reason why it cannot be split into multiple queries. |
Where is the left join in the query in your original question? |
It wasn't indeed. I removed the left join and i'm still receiving this error. The contains is done on a list of int. |
@xaviergxf.
|
@smitpatel & @ErikEJ updated the link to specific section |
Work-around, split the ids list manually on client side. Since documentation does not provide a upper bound of values which can be included, it could be difficult to solve this in EF Core. (i.e. if the upper bound is based on size? int/string/guid could have different sizes). Even if EF Core breaks query in multiple parts based on some number and combine results on client, it would work only simple cases. If the query is being composed further then it could cause a huge client evaluation. And the logic of splitting can get really complex. The SQL work-around to use temporary table could be useful in this scenario but we cannot apply that for all cases. |
@ralmsdeveloper unfortunately the ids are not sequential... i have managed to solve this with an workaround. @smitpatel i agree with you that this should be handled somehow on sql server. |
Triage: Agreed that this is a SQL Server issue. Assigning to @divega to suggest some other ways to get the same data back with different kinds of queries. |
Here are a couple of ideas for workarounds:
|
Clearing up milestone in case we want to do something more with this issue before we close it. |
Closing as nothing to do on the EF side. If any of Diego's ideas are to be productized, that would happen as part of TVP support. |
EF 8.0 has native support for this now: #13617. For lower version, see this Stack Overflow question. |
When doing the following sql with ids containing more than 16000 ids:
I'm receiving the following exception:
I was expecting Sql Server to be able to filter the results correctly.
Is it possible this query into multiple times to avoid this error?
Further technical details
EF Core version: 2.01
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 7
IDE: Visual Studio 2017 15.5
Sql Server: 2008 SP2
The text was updated successfully, but these errors were encountered: