Documentation
¶
Index ¶
- func IsDebugEnabled() bool
- func SetDebug(enabled bool)
- type BushyJoinTreeBuilder
- type CardinalityEstimator
- type CostModel
- type DPJoinReorder
- type DPState
- type GraphStats
- type JoinEdge
- type JoinGraph
- func (jg *JoinGraph) AddEdge(from, to, joinType string, cardinality float64)
- func (jg *JoinGraph) AddNode(name string, cardinality int64)
- func (jg *JoinGraph) EstimateJoinCardinality(from, to string) float64
- func (jg *JoinGraph) Explain() string
- func (jg *JoinGraph) FindMinSpanningTree() []*JoinEdge
- func (jg *JoinGraph) GetConnectedComponents() [][]string
- func (jg *JoinGraph) GetDegreeSequence() []int
- func (jg *JoinGraph) GetNeighbors(name string) []string
- func (jg *JoinGraph) GetNode(name string) *JoinNode
- func (jg *JoinGraph) GetStats() GraphStats
- func (jg *JoinGraph) IsStarGraph() bool
- type JoinNode
- type JoinType
- type LogicalPlan
- type ReorderCache
- type ReorderResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDebugEnabled ¶ added in v0.3.1
func IsDebugEnabled() bool
IsDebugEnabled returns whether debug logging is enabled.
Types ¶
type BushyJoinTreeBuilder ¶
type BushyJoinTreeBuilder struct {
// contains filtered or unexported fields
}
BushyJoinTreeBuilder Bushy Join Tree构建器 支持非线性(bushy)的JOIN树,提升多表JOIN性能
func NewBushyJoinTreeBuilder ¶
func NewBushyJoinTreeBuilder(costModel *cost.AdaptiveCostModel, estimator interface{}, maxBushiness int) *BushyJoinTreeBuilder
NewBushyJoinTreeBuilder 创建Bushy JOIN Tree构建器
func (*BushyJoinTreeBuilder) BuildBushyTree ¶
func (bjtb *BushyJoinTreeBuilder) BuildBushyTree(tables []string, joinNodes interface{}) interface{}
BuildBushyTree 构建Bushy JOIN Tree
func (*BushyJoinTreeBuilder) Explain ¶
func (bjtb *BushyJoinTreeBuilder) Explain() string
Explain 解释Bushy Tree构建器
type CardinalityEstimator ¶
CardinalityEstimator 基数估算器接口
type CostModel ¶
type CostModel interface {
ScanCost(tableName string, rowCount int64, useIndex bool) float64
JoinCost(left, right LogicalPlan, joinType JoinType, conditions []*parser.Expression) float64
}
CostModel 成本模型接口
type DPJoinReorder ¶
type DPJoinReorder struct {
// contains filtered or unexported fields
}
DPJoinReorder DP算法JOIN重排序器 使用动态规划算法寻找最优JOIN顺序
func NewDPJoinReorder ¶
func NewDPJoinReorder(costModel CostModel, estimator CardinalityEstimator, maxTables int) *DPJoinReorder
NewDPJoinReorder 创建DP JOIN重排序器
func (*DPJoinReorder) Explain ¶
func (dpr *DPJoinReorder) Explain(result *ReorderResult) string
Explain 解释重排序结果
func (*DPJoinReorder) Reorder ¶
func (dpr *DPJoinReorder) Reorder(ctx context.Context, plan LogicalPlan) (LogicalPlan, error)
Reorder JOIN重排序(入口函数)
type GraphStats ¶
type GraphStats struct {
NodeCount int
EdgeCount int
MaxDegree int
MinDegree int
AvgDegree float64
IsConnected bool
IsStar bool
}
GraphStats 图统计信息
type JoinEdge ¶
type JoinEdge struct {
From string // 起始表
To string // 目标表
JoinType string // 连接类型
Cardinality float64 // 估算的基数
}
JoinEdge JOIN图边
type JoinGraph ¶
type JoinGraph struct {
// contains filtered or unexported fields
}
JoinGraph JOIN关系图 用于表示表之间的连接关系,辅助JOIN重排序
func (*JoinGraph) EstimateJoinCardinality ¶
EstimateJoinCardinality 估算JOIN的基数(基于图)
func (*JoinGraph) FindMinSpanningTree ¶
FindMinSpanningTree 查找最小生成树(Kruskal算法)
func (*JoinGraph) GetConnectedComponents ¶
GetConnectedComponents 获取连通分量
func (*JoinGraph) GetDegreeSequence ¶
GetDegreeSequence 获取度数序列(用于判断是否是星型图)
func (*JoinGraph) GetNeighbors ¶
GetNeighbors 获取节点的邻居(有向图,只返回出边方向)
func (*JoinGraph) IsStarGraph ¶
IsStarGraph 判断是否是星型图(一个中心节点连接所有其他节点)
type JoinNode ¶
type JoinNode struct {
Name string // 表名
Degree int // 度数(连接的边数)
Edges []*JoinEdge // 连接的边
Cardinality int64 // 表基数(可选)
}
JoinNode JOIN图节点
type LogicalPlan ¶
type LogicalPlan interface {
Children() []LogicalPlan
Explain() string
}
LogicalPlan 逻辑计划接口(避免循环依赖)
type ReorderCache ¶
type ReorderCache struct {
// contains filtered or unexported fields
}
ReorderCache 重排序缓存
func (*ReorderCache) Set ¶
func (rc *ReorderCache) Set(key string, result *ReorderResult)
Set 设置缓存的排序结果
type ReorderResult ¶
type ReorderResult struct {
Order []string
Cost float64
JoinTreeType string // "left-deep", "right-deep", "bushy"
Plan LogicalPlan
}
ReorderResult 重排序结果