`EVENT_NAME` varchar(128) NOT NULL,
`COUNT_STAR` bigint(20) unsigned NOT NULL,
`SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
- `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
- `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
- `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
+ `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL, // not used
+ `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL, // not used
+ `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL // not used
) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
**************************************************************************/
+// one row of data
type table_row struct {
EVENT_NAME string
COUNT_STAR uint64
SUM_TIMER_WAIT uint64
}
+// a table of rows
type table_rows []table_row
+// select the rows into table
func select_rows(dbh *sql.DB) table_rows {
var t table_rows
lib.Logger.Println("events_stages_summary_global_by_event_name.select_rows()")
- // we collect all information even if it's mainly empty as we may reference it later
sql := "SELECT EVENT_NAME, COUNT_STAR, SUM_TIMER_WAIT FROM events_stages_summary_global_by_event_name WHERE SUM_TIMER_WAIT > 0"
rows, err := dbh.Query(sql)
return my_totals.SUM_TIMER_WAIT > t2_totals.SUM_TIMER_WAIT
}
+// generate the totals of a table
func (t table_rows) totals() table_row {
var totals table_row
totals.EVENT_NAME = "Totals"
return totals
}
-func (this *table_row) name() string {
- return this.EVENT_NAME
+// return the stage name, removing any leading stage/sql/
+func (r *table_row) name() string {
+ if len(r.EVENT_NAME) > 10 && r.EVENT_NAME[0:10] == "stage/sql/" {
+ return r.EVENT_NAME[10:]
+ } else {
+ return r.EVENT_NAME
+ }
}
+// stage name limited to 40 characters
func (r *table_row) pretty_name() string {
s := r.name()
- if len(s) > 30 {
- s = s[:29]
+ if len(s) > 40 {
+ s = s[:39]
}
return s
}
+// add the values of one row to another one
func (this *table_row) add(other table_row) {
this.SUM_TIMER_WAIT += other.SUM_TIMER_WAIT
this.COUNT_STAR += other.COUNT_STAR
}
}
+// stage headings
func (r *table_row) headings() string {
- return fmt.Sprintf("%-30s %10s %6s %6s", "Stage Name", "Latency", "%", "Count")
+ return fmt.Sprintf("%-40s|%10s %6s %8s|", "Stage Name", "Latency", "%", "Counter")
}
// generate a printable result
name = ""
}
- return fmt.Sprintf("%-30s|%10s %6s %6s",
+ return fmt.Sprintf("%-40s|%10s %6s %8s|",
name,
lib.FormatTime(r.SUM_TIMER_WAIT),
lib.FormatPct(lib.MyDivide(r.SUM_TIMER_WAIT, totals.SUM_TIMER_WAIT)),
// describe a whole row
func (r table_row) String() string {
- return fmt.Sprintf("%-30s %10s %10s",
+ return fmt.Sprintf("%-40s %10s %10s",
r.pretty_name(),
lib.FormatTime(r.SUM_TIMER_WAIT),
lib.FormatAmount(r.COUNT_STAR))
+// public interface to events_stages_summary_global_by_event_name
package events_stages_summary_global_by_event_name
import (
lib.Logger.Println("Table_io_waits_summary_by_table.Collect() END, took:", time.Duration(time.Since(start)).String())
}
+// return the headings of the object
func (t *Object) Headings() string {
return t.totals.headings()
}
+// return a slice of strings containing the row content
func (t Object) RowContent(max_rows int) []string {
rows := make([]string, 0, max_rows)
return rows
}
+// return an empty row
func (t Object) EmptyRowContent() string {
var e table_row
return e.row_content(e)
}
+// return a row containing the totals
func (t Object) TotalRowContent() string {
return t.totals.row_content(t.totals)
}
+// describe the stages
func (t Object) Description() string {
count := t.count_rows()
return fmt.Sprintf("Latency by SQL stage (events_stages_summary_global_by_event_name) %d rows", count)
}
+// reset the statistics to current values
func (t *Object) SyncReferenceValues() {
+ t.SetNow()
+ t.initial = make(table_rows, len(t.current))
+ copy(t.initial, t.current)
+
+ t.make_results()
}
+// generate the results and totals and sort data
func (t *Object) make_results() {
// lib.Logger.Println( "- t.results set from t.current" )
t.results = make(table_rows, len(t.current))
t.totals = t.results.totals()
}
+// count the number of rows we have data for
func (t Object) count_rows() int {
var count int
for row := range t.results {