Documentation ¶
Index ¶
- func BreakExpressionInLHSandRHS(ctx *plancontext.PlanningContext, expr sqlparser.Expr, lhs semantics.TableSet) (bvNames []string, columns []*sqlparser.ColName, rewrittenExpr sqlparser.Expr, ...)
- func CreatePhysicalOperator(ctx *plancontext.PlanningContext, opTree abstract.LogicalOperator) (abstract.PhysicalOperator, error)
- func PushOutputColumns(ctx *plancontext.PlanningContext, op abstract.PhysicalOperator, ...) (abstract.PhysicalOperator, []int, error)
- func PushPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr, ...) (abstract.PhysicalOperator, error)
- func RemovePredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr, ...) (abstract.PhysicalOperator, error)
- func VisitOperators(op abstract.PhysicalOperator, ...) error
- type ApplyJoin
- func (a *ApplyJoin) CheckValid() error
- func (a *ApplyJoin) Clone() abstract.PhysicalOperator
- func (a *ApplyJoin) Compact(semTable *semantics.SemTable) (abstract.Operator, error)
- func (a *ApplyJoin) Cost() int
- func (a *ApplyJoin) IPhysical()
- func (a *ApplyJoin) TableID() semantics.TableSet
- func (a *ApplyJoin) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr
- type CorrelatedSubQueryOp
- func (c *CorrelatedSubQueryOp) CheckValid() error
- func (c *CorrelatedSubQueryOp) Clone() abstract.PhysicalOperator
- func (c *CorrelatedSubQueryOp) Cost() int
- func (c *CorrelatedSubQueryOp) IPhysical()
- func (c *CorrelatedSubQueryOp) TableID() semantics.TableSet
- func (c *CorrelatedSubQueryOp) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr
- type Cost
- type Delete
- func (d *Delete) CheckValid() error
- func (d *Delete) Clone() abstract.PhysicalOperator
- func (d *Delete) Cost() int
- func (d *Delete) GetQTable() *abstract.QueryTable
- func (d *Delete) GetVTable() *vindexes.Table
- func (d *Delete) IPhysical()
- func (d *Delete) TableID() semantics.TableSet
- func (d *Delete) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr
- type Derived
- func (d *Derived) CheckValid() error
- func (d *Derived) Clone() abstract.PhysicalOperator
- func (d *Derived) Cost() int
- func (d *Derived) IPhysical()
- func (d *Derived) IsMergeable(ctx *plancontext.PlanningContext) bool
- func (d *Derived) TableID() semantics.TableSet
- func (d *Derived) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr
- type Filter
- func (f *Filter) CheckValid() error
- func (f *Filter) Clone() abstract.PhysicalOperator
- func (f *Filter) Compact(semTable *semantics.SemTable) (abstract.Operator, error)
- func (f *Filter) Cost() int
- func (f *Filter) IPhysical()
- func (f *Filter) TableID() semantics.TableSet
- func (f *Filter) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr
- type Route
- func (r *Route) CheckValid() error
- func (r *Route) Clone() abstract.PhysicalOperator
- func (r *Route) Compact(semTable *semantics.SemTable) (abstract.Operator, error)
- func (r *Route) Cost() int
- func (*Route) IPhysical()
- func (r *Route) IsSingleShard() bool
- func (r *Route) PickBestAvailableVindex()
- func (r *Route) SelectedVindex() vindexes.Vindex
- func (r *Route) TableID() semantics.TableSet
- func (r *Route) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr
- func (r *Route) UpdateRoutingLogic(ctx *plancontext.PlanningContext, expr sqlparser.Expr) error
- func (r *Route) VindexExpressions() []sqlparser.Expr
- type SubQueryInner
- type SubQueryOp
- type Table
- func (to *Table) CheckValid() error
- func (to *Table) Clone() abstract.PhysicalOperator
- func (to *Table) Compact(semTable *semantics.SemTable) (abstract.Operator, error)
- func (to *Table) Cost() int
- func (to *Table) GetQTable() *abstract.QueryTable
- func (to *Table) GetVTable() *vindexes.Table
- func (to *Table) IPhysical()
- func (to *Table) PushPredicate(expr sqlparser.Expr, semTable *semantics.SemTable) error
- func (to *Table) TableID() semantics.TableSet
- func (to *Table) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr
- type Union
- type Update
- func (u *Update) CheckValid() error
- func (u *Update) Clone() abstract.PhysicalOperator
- func (u *Update) Cost() int
- func (u *Update) GetQTable() *abstract.QueryTable
- func (u *Update) GetVTable() *vindexes.Table
- func (u *Update) IPhysical()
- func (u *Update) TableID() semantics.TableSet
- func (u *Update) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr
- type Vindex
- func (v *Vindex) CheckValid() error
- func (v *Vindex) Clone() abstract.PhysicalOperator
- func (v *Vindex) Cost() int
- func (v *Vindex) IPhysical()
- func (v *Vindex) PushOutputColumns(columns []*sqlparser.ColName) ([]int, error)
- func (v *Vindex) TableID() semantics.TableSet
- func (v *Vindex) UnsolvedPredicates(*semantics.SemTable) []sqlparser.Expr
- type VindexOption
- type VindexPlusPredicates
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BreakExpressionInLHSandRHS ¶
func BreakExpressionInLHSandRHS( ctx *plancontext.PlanningContext, expr sqlparser.Expr, lhs semantics.TableSet, ) (bvNames []string, columns []*sqlparser.ColName, rewrittenExpr sqlparser.Expr, err error)
BreakExpressionInLHSandRHS takes an expression and extracts the parts that are coming from one of the sides into `ColName`s that are needed
func CreatePhysicalOperator ¶
func CreatePhysicalOperator(ctx *plancontext.PlanningContext, opTree abstract.LogicalOperator) (abstract.PhysicalOperator, error)
func PushOutputColumns ¶
func PushOutputColumns(ctx *plancontext.PlanningContext, op abstract.PhysicalOperator, columns ...*sqlparser.ColName) (abstract.PhysicalOperator, []int, error)
PushOutputColumns will push the columns to the table they originate from, making sure that intermediate operators pass the data through
func PushPredicate ¶
func PushPredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr, op abstract.PhysicalOperator) (abstract.PhysicalOperator, error)
PushPredicate is used to push predicates. It pushed it as far down as is possible in the tree. If we encounter a join and the predicate depends on both sides of the join, the predicate will be split into two parts, where data is fetched from the LHS of the join to be used in the evaluation on the RHS
func RemovePredicate ¶
func RemovePredicate(ctx *plancontext.PlanningContext, expr sqlparser.Expr, op abstract.PhysicalOperator) (abstract.PhysicalOperator, error)
RemovePredicate is used when we turn a predicate into a plan operator, and the predicate needs to be removed as an AST construct
func VisitOperators ¶
func VisitOperators(op abstract.PhysicalOperator, f func(tbl abstract.PhysicalOperator) (bool, error)) error
VisitOperators visits all the operators.
Types ¶
type ApplyJoin ¶
type ApplyJoin struct {
LHS, RHS abstract.PhysicalOperator
// Columns stores the column indexes of the columns coming from the left and right side
// negative value comes from LHS and positive from RHS
Columns []int
// Vars are the arguments that need to be copied from the LHS to the RHS
Vars map[string]int
// LeftJoin will be true in the case of an outer join
LeftJoin bool
// JoinCols are the columns from the LHS used for the join.
// These are the same columns pushed on the LHS that are now used in the Vars field
LHSColumns []*sqlparser.ColName
Predicate sqlparser.Expr
}
ApplyJoin is a nested loop join - for each row on the LHS, we'll execute the plan on the RHS, feeding data from left to right
func (*ApplyJoin) CheckValid ¶
CheckValid implements the PhysicalOperator interface
func (*ApplyJoin) Clone ¶
func (a *ApplyJoin) Clone() abstract.PhysicalOperator
Clone implements the PhysicalOperator interface
func (*ApplyJoin) IPhysical ¶
func (a *ApplyJoin) IPhysical()
IPhysical implements the PhysicalOperator interface
type CorrelatedSubQueryOp ¶
type CorrelatedSubQueryOp struct {
func (*CorrelatedSubQueryOp) CheckValid ¶
func (c *CorrelatedSubQueryOp) CheckValid() error
func (*CorrelatedSubQueryOp) Clone ¶
func (c *CorrelatedSubQueryOp) Clone() abstract.PhysicalOperator
func (*CorrelatedSubQueryOp) Cost ¶
func (c *CorrelatedSubQueryOp) Cost() int
func (*CorrelatedSubQueryOp) IPhysical ¶
func (c *CorrelatedSubQueryOp) IPhysical()
func (*CorrelatedSubQueryOp) TableID ¶
func (c *CorrelatedSubQueryOp) TableID() semantics.TableSet
func (*CorrelatedSubQueryOp) UnsolvedPredicates ¶
func (c *CorrelatedSubQueryOp) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr
type Delete ¶ added in v0.15.0
type Delete struct { QTable *abstract.QueryTable VTable *vindexes.Table OwnedVindexQuery string AST *sqlparser.Delete }
func (*Delete) CheckValid ¶ added in v0.15.0
CheckValid implements the PhysicalOperator interface
func (*Delete) Clone ¶ added in v0.15.0
func (d *Delete) Clone() abstract.PhysicalOperator
Clone implements the PhysicalOperator interface
func (*Delete) GetQTable ¶ added in v0.15.0
func (d *Delete) GetQTable() *abstract.QueryTable
GetQTable implements the IntroducesTable interface
func (*Delete) IPhysical ¶ added in v0.15.0
func (d *Delete) IPhysical()
IPhysical implements the PhysicalOperator interface
type Derived ¶
type Derived struct { Source abstract.PhysicalOperator Query sqlparser.SelectStatement Alias string ColumnAliases sqlparser.Columns // Columns needed to feed other plans Columns []*sqlparser.ColName ColumnsOffset []int }
func (*Derived) CheckValid ¶
CheckValid implements the PhysicalOperator interface
func (*Derived) Clone ¶
func (d *Derived) Clone() abstract.PhysicalOperator
Clone implements the PhysicalOperator interface
func (*Derived) IPhysical ¶
func (d *Derived) IPhysical()
IPhysical implements the PhysicalOperator interface
func (*Derived) IsMergeable ¶ added in v0.14.4
func (d *Derived) IsMergeable(ctx *plancontext.PlanningContext) bool
IsMergeable is not a great name for this function. Suggestions for a better one are welcome! This function will return false if the derived table inside it has to run on the vtgate side, and so can't be merged with subqueries This logic can also be used to check if this is a derived table that can be had on the left hand side of a vtgate join. Since vtgate joins are always nested loop joins, we can't execute them on the RHS if they do some things, like LIMIT or GROUP BY on wrong columns
type Filter ¶
type Filter struct { Source abstract.PhysicalOperator Predicates []sqlparser.Expr }
func (*Filter) CheckValid ¶
CheckValid implements the PhysicalOperator interface
func (*Filter) Clone ¶
func (f *Filter) Clone() abstract.PhysicalOperator
Clone implements the PhysicalOperator interface
func (*Filter) IPhysical ¶
func (f *Filter) IPhysical()
IPhysical implements the PhysicalOperator interface
type Route ¶
type Route struct { Source abstract.PhysicalOperator RouteOpCode engine.Opcode Keyspace *vindexes.Keyspace // here we store the possible vindexes we can use so that when we add predicates to the plan, // we can quickly check if the new predicates enables any new vindex Options VindexPreds []*VindexPlusPredicates // the best option available is stored here Selected *VindexOption // The following two fields are used when routing information_schema queries SysTableTableSchema []evalengine.Expr SysTableTableName map[string]evalengine.Expr // SeenPredicates contains all the predicates that have had a chance to influence routing. // If we need to replan routing, we'll use this list SeenPredicates []sqlparser.Expr // TargetDestination specifies an explicit target destination tablet type TargetDestination key.Destination }
func (*Route) CheckValid ¶
CheckValid implements the Operator interface
func (*Route) Clone ¶
func (r *Route) Clone() abstract.PhysicalOperator
Clone implements the PhysicalOperator interface
func (*Route) IPhysical ¶
func (*Route) IPhysical()
IPhysical implements the PhysicalOperator interface
func (*Route) IsSingleShard ¶
func (*Route) PickBestAvailableVindex ¶
func (r *Route) PickBestAvailableVindex()
PickBestAvailableVindex goes over the available vindexes for this route and picks the best one available.
func (*Route) SelectedVindex ¶
func (*Route) UnsolvedPredicates ¶
UnsolvedPredicates implements the Operator interface
func (*Route) UpdateRoutingLogic ¶
func (r *Route) UpdateRoutingLogic(ctx *plancontext.PlanningContext, expr sqlparser.Expr) error
func (*Route) VindexExpressions ¶
type SubQueryInner ¶
type SubQueryInner struct { Inner abstract.LogicalOperator // ExtractedSubquery contains all information we need about this subquery ExtractedSubquery *sqlparser.ExtractedSubquery }
type SubQueryOp ¶
type SubQueryOp struct {
Outer, Inner abstract.PhysicalOperator
Extracted *sqlparser.ExtractedSubquery
}
func (*SubQueryOp) CheckValid ¶
func (s *SubQueryOp) CheckValid() error
CheckValid implements the PhysicalOperator interface
func (*SubQueryOp) Clone ¶
func (s *SubQueryOp) Clone() abstract.PhysicalOperator
Clone implements the PhysicalOperator interface
func (*SubQueryOp) Cost ¶
func (s *SubQueryOp) Cost() int
Cost implements the PhysicalOperator interface
func (*SubQueryOp) IPhysical ¶
func (s *SubQueryOp) IPhysical()
IPhysical implements the PhysicalOperator interface
func (*SubQueryOp) TableID ¶
func (s *SubQueryOp) TableID() semantics.TableSet
TableID implements the PhysicalOperator interface
func (*SubQueryOp) UnsolvedPredicates ¶
func (s *SubQueryOp) UnsolvedPredicates(semTable *semantics.SemTable) []sqlparser.Expr
UnsolvedPredicates implements the PhysicalOperator interface
type Table ¶
type Table struct { QTable *abstract.QueryTable VTable *vindexes.Table Columns []*sqlparser.ColName }
func (*Table) CheckValid ¶
CheckValid implements the PhysicalOperator interface
func (*Table) Clone ¶
func (to *Table) Clone() abstract.PhysicalOperator
Clone implements the PhysicalOperator interface
func (*Table) GetQTable ¶ added in v0.14.0
func (to *Table) GetQTable() *abstract.QueryTable
GetQTable implements the IntroducesTable interface
func (*Table) IPhysical ¶
func (to *Table) IPhysical()
IPhysical implements the PhysicalOperator interface
func (*Table) PushPredicate ¶
PushPredicate implements the PhysicalOperator interface
type Union ¶
type Union struct { Sources []abstract.PhysicalOperator SelectStmts []*sqlparser.Select Distinct bool // TODO this should be removed. For now it's used to fail queries Ordering sqlparser.OrderBy }
func (*Union) CheckValid ¶
CheckValid implements the PhysicalOperator interface
func (*Union) Clone ¶
func (u *Union) Clone() abstract.PhysicalOperator
Clone implements the PhysicalOperator interface
func (*Union) IPhysical ¶
func (u *Union) IPhysical()
IPhysical implements the PhysicalOperator interface
type Update ¶ added in v0.14.0
type Update struct { QTable *abstract.QueryTable VTable *vindexes.Table Assignments map[string]sqlparser.Expr ChangedVindexValues map[string]*engine.VindexValues OwnedVindexQuery string AST *sqlparser.Update }
func (*Update) CheckValid ¶ added in v0.14.0
CheckValid implements the PhysicalOperator interface
func (*Update) Clone ¶ added in v0.14.0
func (u *Update) Clone() abstract.PhysicalOperator
Clone implements the PhysicalOperator interface
func (*Update) GetQTable ¶ added in v0.14.0
func (u *Update) GetQTable() *abstract.QueryTable
GetQTable implements the IntroducesTable interface
func (*Update) IPhysical ¶ added in v0.14.0
func (u *Update) IPhysical()
IPhysical implements the PhysicalOperator interface
type Vindex ¶
type Vindex struct { OpCode engine.VindexOpcode Table abstract.VindexTable Vindex vindexes.Vindex Solved semantics.TableSet Columns []*sqlparser.ColName Value sqlparser.Expr }
func (*Vindex) CheckValid ¶
CheckValid implements the Operator interface
func (*Vindex) Clone ¶
func (v *Vindex) Clone() abstract.PhysicalOperator
Clone implements the PhysicalOperator interface
func (*Vindex) IPhysical ¶
func (v *Vindex) IPhysical()
IPhysical implements the PhysicalOperator interface
func (*Vindex) PushOutputColumns ¶
type VindexOption ¶
type VindexOption struct { Ready bool Values []evalengine.Expr // columns that we have seen so far. Used only for multi-column vindexes so that we can track how many columns part of the vindex we have seen ColsSeen map[string]any ValueExprs []sqlparser.Expr Predicates []sqlparser.Expr OpCode engine.Opcode FoundVindex vindexes.Vindex Cost Cost }
VindexOption stores the information needed to know if we have all the information needed to use a vindex
type VindexPlusPredicates ¶
type VindexPlusPredicates struct { TableID semantics.TableSet ColVindex *vindexes.ColumnVindex // during planning, we store the alternatives found for this route in this slice Options []*VindexOption }
VindexPlusPredicates is a struct used to store all the predicates that the vindex can be used to query