horoscope

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PlanHint = model.NewCIStr("NTH_PLAN")
)

Functions

func IsSubOptimal

func IsSubOptimal(defPlan *Bench, plan *Bench) bool

func Plan

func Plan(node ast.StmtNode, hints *[]*ast.TableOptimizerHint, planId int64) (string, error)

Types

type Bench

type Bench struct {
	Plan        uint64
	SQL         string
	Hints       executor.Hints
	Explanation executor.Rows
	Cost        *Metrics
	// use q-error to calc the cardinality error
	BaseTableCardInfo []*executor.CardinalityInfo
	JoinTableCardInfo []*executor.CardinalityInfo
}

type BenchCollection

type BenchCollection []*Benches

func (*BenchCollection) Output

func (c *BenchCollection) Output(format string) error

func (*BenchCollection) Table

func (c *BenchCollection) Table() Table

type Benches

type Benches struct {
	VerifiedFail bool
	QueryID      string
	Query        ast.StmtNode
	Type         QueryType
	Round        uint
	DefaultPlan  Bench
	Plans        []*Bench
}

type Cardinalitor

type Cardinalitor struct {
	Type         CardinalityQueryType
	TableColumns map[string][]string
	Timeout      time.Duration
	// contains filtered or unexported fields
}

func NewCardinalitor

func NewCardinalitor(exec executor.Executor, tableColumns map[string][]string, typ CardinalityQueryType, timeout time.Duration) *Cardinalitor

func (*Cardinalitor) Test

func (c *Cardinalitor) Test() (map[string]map[string]map[string]*Metrics, error)

type CardinalityQueryType

type CardinalityQueryType string
const (
	TypeEMQ CardinalityQueryType = "emq"
	TypeRGE CardinalityQueryType = "rge"
	TypeDCT CardinalityQueryType = "dct"
)

type Horoscope

type Horoscope struct {
	// contains filtered or unexported fields
}

func NewHoroscope

func NewHoroscope(exec executor.Executor, differentialExecs []executor.Executor, loader loader.QueryLoader, enableCollectCardError bool) *Horoscope

func (*Horoscope) CollectCardinalityEstimationError

func (h *Horoscope) CollectCardinalityEstimationError(query string) (baseTable []*executor.CardinalityInfo, join []*executor.CardinalityInfo, err error)

func (*Horoscope) Next

func (h *Horoscope) Next(round uint, maxPlans uint64, verify bool, ignoreServerError bool) (benches *Benches, err error)

type Metrics

type Metrics benchstat.Metrics

func RunSQLWithTime added in v1.0.0

func RunSQLWithTime(exec executor.Executor, round uint, query string, tp QueryType) (*Metrics, []executor.Comparable, error)

func (*Metrics) Diff

func (m *Metrics) Diff() float64

type QueryType

type QueryType uint8
const (
	DQL QueryType = iota
	DML
)

func AnalyzeQuery

func AnalyzeQuery(query ast.StmtNode, sql string) (tp QueryType, hints *[]*ast.TableOptimizerHint, err error)

type Row

type Row struct {
	QueryId           string             `json:"queryID"`
	Query             string             `json:"query"`
	PlanSpaceCount    int                `json:"planSpaceSize"`
	DefaultPlanId     int                `json:"defaultPlanID"`
	DefaultPlanDur    float64            `json:"defaultPlanDur"`
	DefaultPlanDurDev float64            `json:"defaultPlanDurDev"`
	BestPlanDur       float64            `json:"bestPlanDur"`
	BestPlanDurDev    float64            `json:"bestPlanDurDev"`
	OptimalPlan       []string           `json:"optimalPlan"`
	Effectiveness     float64            `json:"effectiveness"`
	EstRowsQError     map[string]float64 `json:"-"`
}

type ServerError added in v1.0.0

type ServerError struct {
	// contains filtered or unexported fields
}

ServerError wraps server error

type Table

type Table struct {
	Metric  string   `json:"metric"`
	Headers []string `json:"-"`
	Rows    []*Row   `json:"data"`
}

Table is used for displaying in output

func (Table) String

func (t Table) String() string

Jump to

Keyboard shortcuts

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