vtexplain

package
v3.0.0-rc.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2018 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package vtexplain analyzes a set of sql statements and returns the corresponding vtgate and vttablet query plans that will be executed on the given statements

Package vtexplain analyzes a set of sql statements and returns the corresponding vtgate and vttablet query plans that will be executed on the given statements

Index

Constants

View Source
const (
	// ModeMulti is the default mode with autocommit implemented at vtgate
	ModeMulti = "multi"

	// ModeTwoPC enables the twopc feature
	ModeTwoPC = "twopc"
)

Variables

This section is empty.

Functions

func ExplainsAsJSON

func ExplainsAsJSON(explains []*Explain) string

ExplainsAsJSON returns a json representation of the explains

func ExplainsAsText

func ExplainsAsText(explains []*Explain) string

ExplainsAsText returns a text representation of the explains in logical time order

func Init

func Init(vSchemaStr, sqlSchema string, opts *Options) error

Init sets up the fake execution environment

func Stop

func Stop()

Stop and cleans up fake execution environment

Types

type ExecutorMode

type ExecutorMode string

ExecutorMode controls the mode of operation for the vtexplain simulator

type Explain

type Explain struct {
	// original sql statement
	SQL string

	// the vtgate plan(s)
	Plans []*engine.Plan

	// list of queries / bind vars sent to each tablet
	TabletActions map[string]*TabletActions
}

Explain defines how vitess will execute a given sql query, including the vtgate query plans and all queries run on each tablet.

func Run

func Run(sql string) ([]*Explain, error)

Run the explain analysis on the given queries

type ExplainTopo

type ExplainTopo struct {
	// Map of keyspace name to vschema
	Keyspaces map[string]*vschemapb.Keyspace

	// Map of ks/shard to test tablet connection
	TabletConns map[string]*explainTablet

	// Synchronization lock
	Lock sync.Mutex

	// Number of shards for sharded keyspaces
	NumShards int
}

ExplainTopo satisfies the srvtopo.Server interface. Modeled after the vtgate test sandboxTopo

func (*ExplainTopo) GetSrvKeyspace

func (et *ExplainTopo) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error)

GetSrvKeyspace is part of the srvtopo.Server interface.

func (*ExplainTopo) GetSrvKeyspaceNames

func (et *ExplainTopo) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error)

GetSrvKeyspaceNames is part of the srvtopo.Server interface.

func (*ExplainTopo) GetTopoServer

func (et *ExplainTopo) GetTopoServer() *topo.Server

GetTopoServer is part of the srvtopo.Server interface

func (*ExplainTopo) WatchSrvVSchema

func (et *ExplainTopo) WatchSrvVSchema(ctx context.Context, cell string, callback func(*vschemapb.SrvVSchema, error))

WatchSrvVSchema is part of the srvtopo.Server interface.

type MysqlQuery

type MysqlQuery struct {
	// Sequence number of the query
	Time int

	// SQL command sent to the given tablet
	SQL string
}

MysqlQuery defines a query that was sent to a given tablet and how it was processed in mysql

type Options

type Options struct {
	// NumShards indicates the number of shards in the topology
	NumShards int

	// ReplicationMode must be set to either "ROW" or "STATEMENT" before
	// initialization
	ReplicationMode string

	// Normalize controls whether or not vtgate does query normalization
	Normalize bool

	// ExecutionMode must be set to one of the modes above
	ExecutionMode string

	// StrictDDL is used in unit tests only to verify that the schema
	// is parsed properly.
	StrictDDL bool

	// Target is used to override the "database" target in the
	// vtgate session to simulate `USE <target>`
	Target string
}

Options to control the explain process

type TabletActions

type TabletActions struct {
	// Queries sent from vtgate to the tablet
	TabletQueries []*TabletQuery

	// Queries that were run on mysql
	MysqlQueries []*MysqlQuery
}

TabletActions contains the set of operations done by a given tablet

type TabletQuery

type TabletQuery struct {
	// Logical time of the query
	Time int

	// SQL command sent to the given tablet
	SQL string

	// BindVars sent with the command
	BindVars map[string]*querypb.BindVariable
}

TabletQuery defines a query that was sent to a given tablet and how it was processed in mysql

func (*TabletQuery) MarshalJSON

func (tq *TabletQuery) MarshalJSON() ([]byte, error)

MarshalJSON renders the json structure

Jump to

Keyboard shortcuts

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