-
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
StackOverflowException in nested GroupBy query #27094
Comments
For triage SELECT [t].[Value] AS [A], COALESCE(SUM([t].[Id]), 0) AS [B], COALESCE((
SELECT TOP(1) (
SELECT COALESCE(SUM([t1].[Id]), 0)
FROM [Table] AS [t1]
WHERE ([t].[Value] = [t1].[Value]) OR ([t].[Value] IS NULL AND [t1].[Value] IS NULL)) + COALESCE(SUM([t0].[Id]), 0)
FROM [Table] AS [t0]
GROUP BY [t0].[Value]
ORDER BY (SELECT 1)), 0) AS [C]
FROM [Table] AS [t]
GROUP BY [t].[Value] |
Looks like this would have the same perf issue as #27102 (comment). Is this a limitation of the current architecture? |
@bachratyg - If you are talking about this part |
No, my issue is not with c# null behavior. I'd expect that would get translated as My problem is the proposed translation references the table 3 times instead of the necessary 2. I've checked the execution plan in SSMS and that shows that this would hit the table 5 times whereas the translation I would expect (and something similar was generated by EFC5) only hits it 2 times. Considering this is an oversimplified query on an empty table I'd expect actual perf would be worse if the base query is more complex. |
The non-simplified form of the first aggregate is limitation of the fix in patch branch. It will be translated efficiently in 7.0 |
Understood. Then I will have to do some perf regression testing as we're moving from EFC5 to EFC6. Can you point me to an issue where I can track work on this? |
Correlate the scalar subquery with parent SelectExpression Resolves #27094
Correlate the scalar subquery with parent SelectExpression Resolves #27094
Correlate the scalar subquery with parent SelectExpression Resolves #27094
A StackOverflow occurs when a nested group by references an expression from an outer group by. This is a regression, it used to work in EF Core 5.
Repro
Expected translation (approx):
Actual result:
provider and version information
EF Core version: 6.0.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer 6.0.1
Target framework: .NET 6.0
Operating system: Windows 10 21H1
IDE: Visual Studio 2022 17.0.4
The text was updated successfully, but these errors were encountered: