func getStats(sess sqlbuilder.Database) (map[string]int, error) { stats := make(map[string]int) row := sess.Driver().(*sql.DB).QueryRow(`SELECT count(1) AS value FROM pg_prepared_statements`) var value int err := row.Scan(&value) if err != nil { return nil, err } stats["pg_prepared_statements_count"] = value return stats, nil }
func getStats(sess sqlbuilder.Database) (map[string]int, error) { stats := make(map[string]int) res, err := sess.Driver().(*sql.DB).Query(`SHOW GLOBAL STATUS LIKE '%stmt%'`) if err != nil { return nil, err } var result struct { VariableName string `db:"Variable_name"` Value int `db:"Value"` } iter := sqlbuilder.NewIterator(res) for iter.Next(&result) { stats[result.VariableName] = result.Value } return stats, nil }