-
Notifications
You must be signed in to change notification settings - Fork 824
Expand file tree
/
Copy pathOperations.Top.cshtml
More file actions
118 lines (114 loc) · 4.75 KB
/
Operations.Top.cshtml
File metadata and controls
118 lines (114 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
@model OperationsTopModel
@{
var i = Model.CurrentInstance;
var topOps = Model.TopOperations;
var errorMessage = Model.ErrorMessage;
if (i == null) { return; }
}
@functions
{
string ReadableTime(long microSeconds) => TimeSpan.FromMilliseconds(microSeconds / 1000d).ToTimeStringMini();
string SortLink(SQLInstance.TopSorts sort, string title)
{
<th class="sortable@(sort == Model.TopSearchOptions.Sort ? " current-sort" : "")">
@if (sort == Model.TopSearchOptions.Sort)
{
<span class="current-sort" title="@sort.AsString(EnumFormat.Description)">@title</span>
}
else
{
<a href="?node=@(Model.CurrentInstance.Name)&sort=@(sort.ToString())@(Model.TopSearchOptionsQueryString)" title="Sort by @sort.AsString(EnumFormat.Description)">@title</a>
}
</th>
return null;
}
string RunInLast(DashboardModel.LastRunInterval interval, string label)
{
var secs = (int) interval;
var isChecked = secs == Model.TopSearchOptions.LastRunSeconds;
<label>
<input type="radio" name="LastRunSeconds" value="@secs.ToString()" checked="@isChecked" /> @label
</label>
return null;
}
}
@if (errorMessage.HasValue())
{
<h5 class="page-header">
Unknown Operations on @i.Name
</h5>
<div class="alert alert-danger">
<h5>There was an error fetching server status from @i.Name:</h5>
<p class="error-stack">
@errorMessage
</p>
</div>
}
else
{
<h5 class="page-header">
Top queries on @i.Name @(Model.TopSearchOptions.Sort.HasValue ? " by " + Model.TopSearchOptions.Sort.Value.AsString(EnumFormat.Description) : "")
<span class="pull-right">
<a href="#/sql/top/filters" class="hover-pulsate@(Model.TopSearchOptions.IsNonDefault ? " text-warning" : "")" title="Filter"><i class="fa fa-filter" aria-hidden="true"></i></a>
@*<a href="#" class="js-reload-link">Reload</a>*@
</span>
</h5>
<table class="table table-striped table-hover text-nowrap table-super-condensed table-responsive table-row-actions">
<thead>
<tr class="sort-row sort-category">
<th colspan="3">CPU</th>
<th colspan="2">Time</th>
<th colspan="2">Reads</th>
<th colspan="2">Writes</th>
<th colspan="2">Execs</th>
<th>Time</th>
<th colspan="2">Query Info</th>
</tr>
<tr class="sort-row">
@SortLink(SQLInstance.TopSorts.AvgCPU, "Avg")
@SortLink(SQLInstance.TopSorts.AvgCPUPerMinute, "Avg/min")
@SortLink(SQLInstance.TopSorts.TotalCPU, "Total")
@SortLink(SQLInstance.TopSorts.AvgDuration, "Avg")
@SortLink(SQLInstance.TopSorts.TotalDuration, "Total")
@SortLink(SQLInstance.TopSorts.AvgReads, "Avg")
@SortLink(SQLInstance.TopSorts.TotalReads, "Total")
@SortLink(SQLInstance.TopSorts.AvgWrites, "Avg")
@SortLink(SQLInstance.TopSorts.TotalWrites, "Total")
@SortLink(SQLInstance.TopSorts.ExecutionCount, "Execs")
@SortLink(SQLInstance.TopSorts.ExecutionsPerMinute, "Execs/min")
@SortLink(SQLInstance.TopSorts.LastExecutionTime, "Last Exec")
<th>Database</th>
<th>Query</th>
</tr>
</thead>
<tbody>
@foreach (var o in topOps)
{
<tr class="plan-row" data-plan-handle="@WebEncoders.Base64UrlEncode(o.PlanHandle)" data-offset="@o.StatementStartOffset.ToString()">
<td>@o.AvgCPU.ToComma()µs</td>
<td>@o.AvgCPUPerMinute.ToComma()µs</td>
<td>@ReadableTime(o.TotalCPU)</td>
<td>@ReadableTime(o.AvgDuration)</td>
<td>@ReadableTime(o.TotalDuration)</td>
<td>@o.AvgReads.ToComma()</td>
<td>@o.TotalReads.ToComma()</td>
<td>@o.AvgWrites.ToComma()</td>
<td>@o.TotalWrites.ToComma()</td>
<td>@o.ExecutionCount.ToComma()</td>
<td>@o.ExecutionsPerMinute.ToString("0.00")</td>
<td>@o.LastExecutionTime.ToRelativeTimeSpan()</td>
<td>@o.CompiledOnDatabase</td>
<td class="query-col" title="@o.QueryText">@o.QueryText.TruncateWithEllipsis(80)</td>
</tr>
}
@if (!topOps.Any())
{
<tr>
<td colspan="12">
<div class="no-content">There are no operations in the plan cache on this server.</div>
</td>
</tr>
}
</tbody>
</table>
}