question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

3.0 regression: Produces invalid SQL for complex query

See original GitHub issue

After upgrading to 3.0.0-rc2 daily builds from 2.2.6, a query previously working is now generating invalid SQL. It’s hard for me to make a small reproducible example since it renders into a complex query with lots of columns and joins (292 lines long…), but this is an outline of the resulting query:

SELECT [t14].[lots of columns..], [t21].[lots of columns..], [t28].[lots of columns..]
FROM (
    SELECT TOP(1) [lots of columns..]
    FROM [a table]
    INNER JOIN [other tables..]
    LEFT JOIN [**The Missing Table**] AS [t] ON [...]
	--- here is the table joined in as [t]
	LEFT JOIN [other tables..]
    WHERE [several filters]
    ORDER BY [a column]
) AS [t14]
OUTER APPLY (
    SELECT [t].[a column], [...]
	--- this is the error, it tries to reach [t] in this outer apply
) AS [t21]
OUTER APPLY (
    [other things]
) AS [t28]
LEFT JOIN [...]
[...]
ORDER BY [t14].[lots of columns..], [t21].[lots of columns..], [t28].[lots of columns..]

As you can see it tries to reach [t] from within outer apply but it’s declared in another scope. How do I proceed to investigate this so that I can give you better details of this problem? I do not even know where to start debugging this to make EF Core produce a valid SQL. Perhaps this is something you know about and are already working on right now?

Further technical details

EF Core version: 3.0.0-rc2 daily builds Database provider: Microsoft.EntityFrameworkCore.SqlServer Target framework: .NET Core 3.0 Operating system: Win 10 IDE: Visual Studio 2019 preview

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:31 (30 by maintainers)

github_iconTop GitHub Comments

3reactions
smitpatelcommented, Sep 12, 2019

@jcemoller - Received. Give me few days to investigate. It is a massive query. 😆

2reactions
joakimriedelcommented, Sep 20, 2019

Thanks @smitpatel , I will try this work-around next week. Just wanted to let you know that I have now worked out all (*) the migration issues - and this week we’re finally live with 3.0 code in production! Preliminary results look promising, we’re seeing on average http request times going down from 70 ms to 54 ms with net/ef core 3.0 compared to 2.2.6! Great work!

* I had to skip a single integration test due to some regression in memory provider, will post issue later when I got time to package a reproducible example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL not engaging parallelism for extremely large query
There are many reasons that the optimizer will not (or cannot) produce a parallel plan. Broadly: Obvious causes, such as the configuration ...
Read more >
Inline Replace focuses wrong input - Developer Community
A breaking change in Preview 4 of 17.0 is that when you Hit Control+H / Edit -> Replace the Focused input is put...
Read more >
Best way to test SQL queries [closed]
I have run into a problem wherein we keep having complex SQL queries go out with errors. Essentially this results in sending mail...
Read more >
19 SQL for Analysis and Reporting
Query processing using analytic functions takes place in three stages. First, all joins, WHERE , GROUP BY and HAVING clauses are performed. Second,...
Read more >
Migrating to GoogleSQL | BigQuery
This query returns NULL rather than a timestamp string for invalid timestamp values. GoogleSQL highlights. This section discusses some of the highlights of ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found