go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/vtexplain Index | Files

package vtexplain

import "gopkg.in/src-d/go-vitess.v1/vt/vtexplain"

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

Package Files

vtexplain.go vtexplain_topo.go vtexplain_vtgate.go vtexplain_vttablet.go

Constants

const (

    // ModeMulti is the default mode with autocommit implemented at vtgate
    ModeMulti = "multi"

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

func ExplainsAsJSON Uses

func ExplainsAsJSON(explains []*Explain) string

ExplainsAsJSON returns a json representation of the explains

func ExplainsAsText Uses

func ExplainsAsText(explains []*Explain) string

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

func Init Uses

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

Init sets up the fake execution environment

func Stop Uses

func Stop()

Stop and cleans up fake execution environment

type ExecutorMode Uses

type ExecutorMode string

ExecutorMode controls the mode of operation for the vtexplain simulator

type Explain Uses

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 Uses

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

Run the explain analysis on the given queries

type ExplainTopo Uses

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 Uses

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

GetSrvKeyspace is part of the srvtopo.Server interface.

func (*ExplainTopo) GetSrvKeyspaceNames Uses

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

GetSrvKeyspaceNames is part of the srvtopo.Server interface.

func (*ExplainTopo) GetTopoServer Uses

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

GetTopoServer is part of the srvtopo.Server interface

func (*ExplainTopo) WatchSrvVSchema Uses

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

WatchSrvVSchema is part of the srvtopo.Server interface.

type MysqlQuery Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

MarshalJSON renders the json structure

Package vtexplain imports 34 packages (graph). Updated 2019-06-13. Refresh now. Tools for package owners.