How AsNoTracking() impact on performance ?
Shubham Sidnale
Select an image from your device to upload
I've seen projects where adding AsNoTracking() didn't improve performance much, but it still included too many tables. In your opinion, between Subway Surfers optimizing LINQ projection and using AsNoTracking(), which one is more effective in practice?
In Entity Framework (EF) Core,AsNoTracking() tells the DbContext not to track the entities returned by a query. By default, EF tracks all retrieved objects to automatically detect and save modifications.
AsNoTracking()
DbContext
AsNoTracking() improves performance by 35–40% and reduces memory usage by 50% because it stops the DbContext from snapshotting data or monitoring property changes.
Simple example:
// Use for fast, read-only data (API/Reports) var list = context.Products.AsNoTracking().ToList();// Skip for updates (requires tracking) var item = context.Products.First(); item.Price = 10; context.SaveChanges();
Hope this helps you understand.