Skip to content

Commit

Permalink
Self-review
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <[email protected]>
  • Loading branch information
rohit-nayak-ps committed Dec 10, 2024
1 parent d82bd47 commit 06667ee
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 208 deletions.
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ check_version:

default: check_version build

vt: clean
@echo "Building vt..."
@go build -o vt ./go/vt

build:
@echo "Building vt..."
@go build -o vt ./go/vt
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func Execute() {
Use: "vt",
Short: "Utils tools for testing, running and benchmarking Vitess.",
RunE: func(_ *cobra.Command, _ []string) error {
// Do something with port here
if port > 0 {
if webserverStarted {
return nil
Expand All @@ -64,6 +63,7 @@ func Execute() {
} else {
ch <- 1
}

// FIXME: add sync b/w webserver and root command, for now just add a wait to make sure webserver is running
time.Sleep(2 * time.Second)
err := root.Execute()
Expand Down
191 changes: 173 additions & 18 deletions go/web/templates/summarize.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,182 @@
{{define "content"}}
<h1 class="fixed-header">Query Analysis Report</h1>
<br><br>
<h2>Tables</h2>
<h1>Query Analysis Report</h1>
<table>
<thead>
<tr>
<th>Table Name</th>
<th>Reads</th>
<th>Writes</th>
<th>Number of Rows</th>
<th> Date of Analysis</th>
<th>Analyzed Files</th>
</tr>
</thead>
<tbody>
{{range .Tables}}
<tr>
<td>{{.Table}}</td>
<td>{{.ReadQueryCount}}</td>
<td>{{.WriteQueryCount}}</td>
<td>{{.RowCount}}</td>
<td style="text-align: center">{{.DateOfAnalysis}}</td>
<td style="text-align: center;font-size: larger">{{range .AnalyzedFiles}}<code>{{.}}</code>{{end}}</td>
</tr>
{{end}}
</tbody>
</thead>
</table>

{{end}}
`
<button class="collapsible">Top Queries</button>
<div class="content">
<table>
<thead>
<tr>
<th>Query ID</th>
<th>Usage Count</th>
<th>Total Query Time (ms)</th>
<th>Avg Query Time (ms)</th>
<th>Total Rows Examined</th>
</tr>
</thead>
<tbody>
{{range $index, $query := .HotQueries}}
<tr>
<td>{{$index | add 1}}</td> <!-- Add 1 to start numbering from 1 -->
<td>{{$query.UsageCount}}</td>
<td>{{$query.QueryTime}}</td>
<td>{{divide .QueryTime .UsageCount}}</td>
<td>{{$query.RowsExamined}}</td>
</tr>
{{end}}
</tbody>
</table>
</div>

<button class="collapsible">Query Details</button>
<div class="content">
<table>
<thead>
<tr>
<th>#</th>
<th>Query Structure</th>
</tr>
</thead>
<tbody>
{{range $index, $query := .HotQueries}}
<tr>
<td style="text-align: right">{{$index | add 1}}</td>
<td style="text-align: left"><code>{{.QueryStructure}}</code></td>
</tr>
{{end}}
</tbody>
</table>
</div>

<button class="collapsible">Tables</button>
<div class="content">
<table>
<thead>
<tr>
<th>Table Name</th>
<th>Reads</th>
<th>Writes</th>
<th>Number of Rows</th>
</tr>
</thead>
<tbody>
{{range .Tables}}
<tr>
<td>{{.Table}}</td>
<td>{{.ReadQueryCount}}</td>
<td>{{.WriteQueryCount}}</td>
<td>{{.RowCount}}</td>
</tr>
{{end}}
</tbody>
</table>
</div>

<button class="collapsible">Column Usage</button>
<div class="content" style="margin-bottom: 10px">
{{range .Tables}}
<div class="columnUsage">
<h4>Table: <code>{{.Table}}</code> ({{.ReadQueryCount}} reads and {{.WriteQueryCount}} writes)</h4>
<table>
<thead>
<tr>
<th>Column</th>
<th>Position</th>
<th>Used %</th>
</tr>
</thead>
<tbody>
{{range .GetColumnsSlice}}
<tr>
<td>{{.ColInfo.Name}}</td>
<td>{{.ColInfo.Pos}}</td>
<td>{{.Usage.Percentage}}%</td>
</tr>
{{end}}
</tbody>
</table>
</div>
{{end}}
</div>

<button class="collapsible">Tables Joined</button>
<div class="content">
<table>
<thead>
<tr>
<th>Table 1</th>
<th>Table 2</th>
<th>Occurrences</th>
<th>Predicates</th>
</tr>
</thead>
<tbody>
{{range .Joins}}
<tr>
<td><pre>{{.Tbl1}}</pre></td>
<td><pre>{{.Tbl2}}</pre></td>
<td>{{.Occurrences}}</td>
<td style="text-align: left">
{{range .Predicates}}
<pre>{{.}}</pre>
{{end}}
</td>
</tr>
{{end}}
</tbody>
</table>
</div>

<button class="collapsible">Failures</button>
<div class="content">
<table>
<thead>
<tr>
<th>Error</th>
<th>Count</th>
</tr>
</thead>
<tbody>
{{range .Failures}}
<tr>
<td>{{.Error}}</td>
<td>{{.Count}}</td>
</tr>
{{end}}
</tbody>
</table>
</div>

<button class="collapsible">Transaction Patterns</button>
<div class="content">
{{range $index, $tx := .Transactions}}
<h3>Pattern {{$index | add 1}} (Observed {{$tx.Count}} times)</h3>
<p><strong>Tables Involved:</strong> TBD</p>
<h4>Query Patterns</h4>
{{range $index2, $query := .Queries}}
<p>{{$index | add 1}} . <strong>{{$query.Type}}</strong> on <code>{{$query.Table}}</code></p>
<p>Predicates: {{range $query.Predicates}}{{.}} AND {{end}}</p>
{{end}}
<h4>Shared Predicate Values</h4>
{{range $index3, $join := $tx.Joins}}
<p>Value {{$index | add 1}} applied to:</p>
<ul>
{{range .}}
<li>{{$join}}</li>
{{end}}
</ul>
{{end}}
{{end}}
</div>
{{end}}
Loading

0 comments on commit 06667ee

Please sign in to comment.