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
- func ExplainsAsJSON(explains []*Explain) string
- func ExplainsAsText(explains []*Explain) string
- func Init(vSchemaStr, sqlSchema string, opts *Options) error
- func Stop()
- type ExecutorMode
- type Explain
- type ExplainTopo
- func (et *ExplainTopo) GetSrvKeyspace(ctx context.Context, cell, keyspace string) (*topodatapb.SrvKeyspace, error)
- func (et *ExplainTopo) GetSrvKeyspaceNames(ctx context.Context, cell string) ([]string, error)
- func (et *ExplainTopo) GetTopoServer() *topo.Server
- func (et *ExplainTopo) WatchSrvVSchema(ctx context.Context, cell string, callback func(*vschemapb.SrvVSchema, error))
- type MysqlQuery
- type Options
- type TabletActions
- type TabletQuery
Constants ¶
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 ¶
ExplainsAsJSON returns a json representation of the explains
func ExplainsAsText ¶
ExplainsAsText returns a text representation of the explains in logical time order
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.
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 ¶
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