Documentation
¶
Overview ¶
Package explain turns a server's JSON query plan into something readable.
It knows nothing about tview and nothing about a connection: bytes in, a tree and then lines out. What it deliberately does not know is the plan's schema.
MySQL and MariaDB disagree about that schema, and both change it between versions — MariaDB nests a sort under "read_sorted_file" and a group under "temporary_table", MySQL under "ordering_operation" and "grouping_operation", and neither list is fixed. So the walk is generic: an object's scalar fields are that step's attributes and its object and array fields are its children. What appears on screen is then what the server said, rather than what this package assumed it would say.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render draws the plan as a tree, wrapped to fit width.
Fitting is the whole point rather than a nicety. The reason EXPLAIN is hard to read in a grid is that it is a dozen narrow columns spread sideways, and a tree that overflows has reinvented the problem in a different shape — so nothing here is allowed to reach past the width it was given.
Types ¶
type Node ¶
type Node struct {
// Name is the key the server nested this step under — "query_block",
// "filesort", "table" — or the table's own name where it has one, since
// "table" says less than "dv_x_books".
Name string
// Attrs are the step's scalar fields, in the order they are worth reading
// rather than the order they arrived.
Attrs []Attr
Children []*Node
// Warnings name what will make this step slow, in the words a DBA would
// use rather than the server's.
Warnings []string
// contains filtered or unexported fields
}
Node is one step of a plan.