2. Only tested on MySQL 5.6 and MariaDB 10.0. It should be possible
to make this work on MySQL 5.7 but that has not been tested yet.
+
+3. Latency issues over slow connections. Perhaps should use compressed
+connection to speed things up?
+
+4. Inefficient collection of data. I'm calculating stuff for the
+things I'm not actually displaying, so I should split this so that
+the display part does the calculations when needed and only the raw
+values are collected.
import (
"database/sql"
+ "time"
- // "github.com/sjmudd/pstop/lib"
+ "github.com/sjmudd/pstop/lib"
ps "github.com/sjmudd/pstop/performance_schema"
)
// Collect data from the db, then merge it in.
func (t *File_summary_by_instance) Collect(dbh *sql.DB) {
+ start := time.Now()
// UPDATE current from db handle
t.current = merge_by_table_name(select_fsbi_rows(dbh), t.global_variables)
// setup the totals
t.totals = t.results.totals()
+ lib.Logger.Println("File_summary_by_instance.Collect() took:", time.Duration(time.Since(start)).String())
}
// return the headings for a table
"log"
"regexp"
"sort"
+ "time"
"github.com/sjmudd/pstop/lib"
)
// Convert the imported "table" to a merged one with merged data.
// Combine all entries with the same "FILE_NAME" by adding their values.
func merge_by_table_name(orig file_summary_by_instance_rows, global_variables map[string]string) file_summary_by_instance_rows {
+ start := time.Now()
t := make(file_summary_by_instance_rows, 0, len(orig))
m := make(map[string]file_summary_by_instance_row)
t = append(t, row)
}
+ lib.Logger.Println("merge_by_table_name() took:", time.Duration(time.Since(start)).String())
return t
}
// - change FILE_NAME into a more descriptive value.
func select_fsbi_rows(dbh *sql.DB) file_summary_by_instance_rows {
var t file_summary_by_instance_rows
+ start := time.Now()
sql := "SELECT FILE_NAME, COUNT_STAR, SUM_TIMER_WAIT, COUNT_READ, SUM_TIMER_READ, SUM_NUMBER_OF_BYTES_READ, COUNT_WRITE, SUM_TIMER_WRITE, SUM_NUMBER_OF_BYTES_WRITE, COUNT_MISC, SUM_TIMER_MISC FROM file_summary_by_instance"
if err := rows.Err(); err != nil {
log.Fatal(err)
}
+ lib.Logger.Println("select_fsbi_rows() took:", time.Duration(time.Since(start)).String())
return t
}
import (
"database/sql"
"fmt"
+ "time"
"github.com/sjmudd/pstop/lib"
ps "github.com/sjmudd/pstop/performance_schema"
// values if needed, and then subtracting initial values if we want
// relative values, after which it stores totals.
func (t *Table_io_waits_summary_by_table) Collect(dbh *sql.DB) {
+ start := time.Now()
lib.Logger.Println("Table_io_waits_summary_by_table.Collect() BEGIN")
t.current = select_tiwsbt_rows(dbh)
lib.Logger.Println("- t.current set from", len(t.current), "collected row(s) from SELECT")
// lib.Logger.Println( "t.current:", t.current )
lib.Logger.Println("t.results:", t.results)
lib.Logger.Println("t.totals:", t.totals)
- lib.Logger.Println("Table_io_waits_summary_by_table.Collect() END")
+ lib.Logger.Println("Table_io_waits_summary_by_table.Collect() END, took:", time.Duration(time.Since(start)).String())
}
func (t *Table_io_waits_summary_by_table) make_results() {
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
+ "time"
- // "github.com/sjmudd/pstop/lib"
+ "github.com/sjmudd/pstop/lib"
ps "github.com/sjmudd/pstop/performance_schema"
)
// Collect data from the db, then merge it in.
func (t *Table_lock_waits_summary_by_table) Collect(dbh *sql.DB) {
+ start := time.Now()
t.current = select_tlwsbt_rows(dbh)
if len(t.initial) == 0 && len(t.current) > 0 {
}
t.make_results()
+ lib.Logger.Println("Table_lock_waits_summary_by_table.Collect() took:", time.Duration(time.Since(start)).String())
}
func (t *Table_lock_waits_summary_by_table) make_results() {
}
func (state *State) UpdateInitialValues() {
+ start := time.Now()
state.fsbi.UpdateInitialValues()
state.tlwsbt.UpdateInitialValues()
state.tiwsbt.UpdateInitialValues()
+ lib.Logger.Println("state.UpdateInitialValues() took", time.Duration(time.Since(start)).String())
}
func (state *State) Collect() {
+ start := time.Now()
state.fsbi.Collect(state.dbh)
state.tlwsbt.Collect(state.dbh)
state.tiwsbt.Collect(state.dbh)
+ lib.Logger.Println("state.Collect() took", time.Duration(time.Since(start)).String())
}
func (state State) MySQLVersion() string {