mysqlexplainparser

package module
v0.0.0-...-74d572f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2014 License: MIT Imports: 2 Imported by: 0

README

Build Status

https://godoc.org/github.com/moznion/go-mysql-explain-parser

go-mysql-explain-parser

go-mysql-explain-parser is the parser for result of EXPLAIN of MySQL.

This package is port of MySQL::Explain::Parser from Perl to Go.

Getting Started

go get github.com/moznion/go-mysql-explain-parser

Synopsis

import (
	"github.com/moznion/go-mysql-explain-parser"
)

func main() {

	explain := `
+----+-------------+-------+-------+---------------+---------+---------+------+------+----------+-------------+
| id | select_type | table | type  | possible_keys | key     | key_len | ref  | rows | filtered | Extra       |
+----+-------------+-------+-------+---------------+---------+---------+------+------+----------+-------------+
|  1 | PRIMARY     | t1    | index | NULL          | PRIMARY | 4       | NULL | 4    | 100.00   |             |
|  2 | SUBQUERY    | t2    | index | a             | a       | 5       | NULL | 3    | 100.00   | Using index |
+----+-------------+-------+-------+---------------+---------+---------+------+------+----------+-------------+
`
	mysqlexplainparser.Parse(explain)

	explainVertical := `
*************************** 1. row ***************************
           id: 1
  select_type: PRIMARY
        table: t1
         type: index
possible_keys: NULL
          key: PRIMARY
      key_len: 4
          ref: NULL
         rows: 4
     filtered: 100.00
        Extra:
*************************** 2. row ***************************
           id: 2
  select_type: SUBQUERY
        table: t2
         type: index
possible_keys: a
          key: a
      key_len: 5
          ref: NULL
         rows: 3
     filtered: 100.00
        Extra: Using index
`
	mysqlexplainparser.ParseVertical(explainVertical)
}

Functions

  • func Parse(explain string) []map[string]string

Returns the result of parsed EXPLAIN

  • func ParseVertical(explain string) []map[string]string

Returns the result of parsed EXPLAIN as vertical

See Also

LICENSE

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(explain string) []map[string]string

Parse returns the result of parsed EXPLAIN

func ParseVertical

func ParseVertical(explain string) []map[string]string

ParseVertical returns the result of parsed EXPLAIN as vertical as array of map

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL