source

package
v0.0.0-...-c6d3014 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadBinding

func ReadBinding(
	ctx context.Context,
	db *sql.DB,
) (map[string]Binding, error)

ReadBinding reads all enabled binding information from the TiDB cluster and use a map of SQL digest to Binding to represent them.

func ReadStmtSummary

func ReadStmtSummary(
	ctx context.Context,
	db *sql.DB,
	outCh chan<- *StmtSummary,
) error

ReadStmtSummary reads the statement summary from the TiDB cluster. It emits the StmtSummary one by one into `outCh`, or return error. When work is completed, it will return nil. In any cases it will not close the channel.

TODO(lance6716): can use statements_summary_evicted to calculate confidence TODO(lance6716): query CLUSTER_STATEMENTS_SUMMARY to get real time data

func ReadTableStats

func ReadTableStats(
	ctx context.Context,
	client *http.Client,
	addr string,
	schema, table string,
) (string, error)

Types

type Binding

type Binding struct {
	OriginalSQL string
	BindSQL     string
}

type StmtSummary

type StmtSummary struct {
	// fields from the table
	Schema               string
	SQL                  string
	TableNamesNeedToSync [][2]string
	PlanStr              string
	SQLDigest            string
	PlanDigest           string
	ExecCount            int
	SumLatency           time.Duration
	Instance             string
	SummaryBeginTime     time.Time
	PlanInBinding        bool
	// computed fields
	HasParseError bool
	BindingDigest string
	Binding       Binding
}

StmtSummary represents one record in INFORMATION_SCHEMA.CLUSTER_STATEMENTS_SUMMARY_HISTORY. The Instance + SummaryBeginTime + SQLDigest + PlanDigest fields are used as the ID of the StmtSummary.

Jump to

Keyboard shortcuts

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