-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL Profiling: Network Time not assigned to SQL cost/time #671
Comments
Just to note, that this information does exist, if But you can see the aggregated view hides the fact the SQL call took 60s: |
So I just tested comparing C# code for testing:using (profiler.Step("Using ProfiledDbConnection"))
{
using var connection = ServiceLocator.Get<IDbFactory>().CreateConnection();
var results = connection.Query($@"
SELECT top 10000 *
FROM [dbo].[Table]
");
var output = results.ToList();
}
using (profiler.Step("Using .AddEntityFramework()"))
{
var output = ServiceLocator.Get<IReadOnlyPrimaryUnit>().GetTable<Table>()
.Take(10000)
.ToList();
} You can see the difference in output from MiniProfiler here: And looking at the detailed window: So it does appear as though something is broken in the |
Debugging locally, it seems the issue is with line: It seems Any chance of a fix here? |
Note: I've fixed this for us by using a custom version of The custom version can be injected in by replacing: .AddEntityFramework(); With .Services.AddSingleton<IMiniProfilerDiagnosticListener, RelationalDiagnosticListenerFixIssue671>(); |
The only documentation I can see around profiling SQL is here: https://miniprofiler.com/dotnet/HowTo/ProfileEFCore, and here https://miniprofiler.com/dotnet/HowTo/ProfileSql. It's not clear if these two approaches are equivalent, but the following issue uses the former.
The documentation does not specify what to expect if you have a "fast" SQL query which spends a lot of time transferring data accross the network.
For example let's say we run:
Within a code block like:
This is a simple query, which SQL quickly runs, and Miniprofiler sat on an instance right next to the DB would show a total time close to the query time.
Now let's say we're hundreds of miles away from the DB. The time it takes to run the query on SQL server is still fast, but the overall query time including network transit is slow.
Where would you expect MiniProfiler to allocate that time? As far as I can tell, it does not appear in the SQL time, but makes it appear like the object materialisation is taking up the time:
If I run the exact same SQL query from SQL Server Management Studio, it takes several seconds (not 20ms).
Ideally we could separate out SQL query time from SQL network time, but failing that should the documentation be clearer on what time is being calculated and returned here?
The text was updated successfully, but these errors were encountered: