-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Description
In EFCore3 Preview 7 onwards, there is a significant slow down when I have a query with many .ThenInclude()s, e.g.
new WhyYouSoSlowDb(options)
.Blog
.Include(x => x.Posts)
.ThenInclude(x => x.PostInstances)
.ThenInclude(x => x.Comments)
.ThenInclude(x => x.AcquiredComments)
.ThenInclude(x => x.Tag_AcquiredComments)
.ThenInclude(x => x.Tag)
.FirstOrDefault();
The above takes 20 seconds to run on an empty database. On EFCore3 Preview 5, it takes 1.5 seconds to run. (Preview 6 throws an exception.)
Steps to reproduce
Repo available here. Note that some amount of complexity is required to reproduce this issue - if you delete the 5 unreferenced properties from AcquiredCommentEntity, it will take 10 seconds to run.
Further technical details
EF Core version: EFCore3 Preview 7 and 8
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2019 Preview