Improve performance via optimized EF Core usage
There are several ways we can improve the performance of our queries via Entity Framework Core. This article is several years old at this time, but it's still relevant.
- Disable change tracking for read-only queries.
- Load data eagerly if it's known which data is required (Ex. Use
context.Users.Include(u => u.Stats)if reading from the
- For very expensive queries, consider writing them in raw SQL (via
context.Users.FromSqlRaw). This should be performed only as a last resort.
A good chunk of this is completed in
c45e59dbbe for the important parts.
There's plenty more to do, but the hotspots have shown improvements. One host had about a 1 second delay between when the input message was received and carried out. These changes completely eliminated that delay.
Deleting a branch is permanent. It CANNOT be undone. Continue?