dotnet / dotnet/EntityFramework.Docs
Interceptor methods or events for query start/query consumed
- Dominant language
- Mermaid
- Stars
- 1.7k
- Forks
- 2k
- Avg merge
- 7d 23h
- Merged PRs (30d)
- 16
Description
One of the things I like to try to track during development is the time it takes to materialize and track objects that are returned by a query. The reason I do this is because I have some clients who insist on returning many thousands of rows from a query. They run the query in SSMS and say, "See, it only takes x milliseconds for the query to run, so why does the screen take y seconds to appear?" (or questions along those lines).
If I could intercept when entity materialization starts and stops, as well as when change tracking starts and stops, I could show clients a more complete idea of how long it takes the query to execute in its entirety. I could also easily catch instances in which I might be returning too much data for other reasons.
By extending my DbContext class and handling its ChangeTracker.Tracked event, I've been able to more or less time how long it takes to add objects to the change tracker. But, the hack I came up with is less than elegant. And, it doesn't take into account the overhead required to materialize objects at all.
If this were something that could easily be put into the code base, it would be of benefit to me.
Contributor guide
Assessment
This issue has not been assessed yet.