Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

EF 9 much slower than EF 8 #35268

Closed
f0ppa21 opened this issue Dec 4, 2024 · 1 comment
Closed

EF 9 much slower than EF 8 #35268

f0ppa21 opened this issue Dec 4, 2024 · 1 comment

Comments

@f0ppa21
Copy link

f0ppa21 commented Dec 4, 2024

File a bug

EF 9 is much slower in our project on queries that results in a large/complex data-model.
When returning 2700 records in the example below the operation takes more than double the time in EF 9 compared to EF 8:
2.8 sec vs. 1.2 sec
With more returned records this difference also gets exponentially worse.

The generated Sql-query (using split query) itself is not slower (has checked with SQL Profiler), it seems that the ToListAsync-operation is much slower than in EF 8?!

We have now reverted to use EF 8 with .NET 9, but are hoping you can fix this in upcoming EF-patches!

Include your code

var drivningsenheter = await _context.Drivningsenheter
.Include(d => d.Taxeringsvolymer)
.Include(d => d.SchemalagdaDrivningar).ThenInclude(p => p.Lag)
.Include(d => d.SchemalagdaDrivningar).ThenInclude(p => p.Produktionsledare)
.Include(d => d.SchemalagdaDrivningar).ThenInclude(p => p.Produktionsomrade)
.Include(d => d.SchemalagdaDrivningar).ThenInclude(p => p.SchemalagdaVolymer).ThenInclude(p => p.DestineringSortiment).ThenInclude(s => s.ProduceratHandelssortiment)
.Include(d => d.SchemalagdaDrivningar).ThenInclude(p => p.SchemalagdaVolymer).ThenInclude(p => p.DestineringMottagningsplats).ThenInclude(s => s.Mottagningsplats)
.Include(d => d.Viapunkt).ThenInclude(v => v!.Viapunktkluster).ThenInclude(v => v!.Standarddestineringar).ThenInclude(v => v.DestineringMottagningsplats).ThenInclude(s => s.Mottagningsplats)
.Include(d => d.Viapunkt).ThenInclude(v => v!.Viapunktkluster).ThenInclude(v => v!.Standarddestineringar).ThenInclude(v => v.DestineringSortiment).ThenInclude(s => s.ProduceratHandelssortiment)
.Include(d => d.Avlaggskvantiteter).ThenInclude(a => a.Avlagg)
.Include(d => d.Flodesomrade)
.Include(d => d.Ursprung)
.Include(d => d.Huggningsform)
.Include(d => d.Terrangbarighet)
.Include(d => d.Vagbarighet)
.Include(d => d.Arstid)
.Include(d => d.Traktplaneringsmetod)
.Include(d => d.Kommentarer)
.Include(d => d.Kommun)
.Include(d => d.LokaltTeam)
.Where(d => request.Flodesomraden.Contains(d.FlodesomradeId) && !d.Fardig)
.AsNoTracking()
.ToListAsync(cancellationToken);

Include stack traces

Include verbose output

Include provider and version information

EF Core version: 9.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 9.0
Operating system:
IDE: Visual Studio 2022 17.12.2

@ajcvickers
Copy link
Contributor

Duplicate of #35053

@ajcvickers ajcvickers marked this as a duplicate of #35053 Dec 4, 2024
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants