Planner Operators for MariaDB Xpand
This page is part of MariaDB's Documentation.
The parent of this page is: Query Plans for MariaDB Xpand
Topics on this page:
Overview
This section lists the operators used by the Xpand Planner to find an optimal execution plan. For more on using and interpreting EXPLAIN
, see EXPLAIN
for MariaDB Xpand.
Operators
Xpand has a streaming model which streams rows starting from containers (tables and indexes) and through a graph of operators. Xpand has a rich set of operators that occasionally increase as more functionality and optimizations are added. We use one place for documenting our operators, logical and physical. The physical operators show up in explain output and logical ones do not, so this is a superset of operators you will see.
Common Operators
These are the common operators one will see in the explain output from MySQL prompt.
Operator | Arguments | Details |
---|---|---|
display | (REFS [output_ | Display output to user.
| output_ |
stream_ | () INPUT_ | Take an input that generates separate streams (such as an index_ INPUT_ |
stream_ | () INPUT_ | Similar to stream_ INPUT_ |
index_ | (NAMESPACE RELOID REPOID COLS . PROPS) EQUAL LOW HIGH NULLF? | Scan the representation. Namespaces are unique per relation.
| NAMESPACE := vs32
| RELOID := object ID of relation
| REPOID := object ID of index
| COLS := list of columns needed
| PROPS := list of 0 or more of: read_ |
table_ | (NAMESPACE OID COLS . PROPS) . EXPR | NAMESPACE := vs32 that represents which namespace
OID := object ID of table
COLS := list of columns needed
PROPS := list of 0 more of: update, use_
EXPR := list of constraints to apply to the output
|
filter | () INPUT_ | Apply filter to input.
| EXPR := item operator; null, 0, and false are filtered out
| INPUT_ |
row_ | CALC_ | Limit the number of rows produced. This operator can stop previous input operators from producing rows once it has enough rows.
| CALC_ |
row_ | NAME INPUT_ | Counts the number of rows produced. Assigns to NAME. |
user_ | VALUE | User provided constant. VALUE := constant. |
const | VALUE | VALUE := constant. |
ref | (NAMESPACE . NAME) | NAMESPACE := vs32 of the namespace
NAME := string of the column name
|
param | (VALUE) | VALUE := u32 denoting which prepared parameter it is |
range | MODE EXPR... | MODE := closed, open, equal
EXPR := expression for each column in the range
|
force_ | PROP INPUT_ | Physical operator that forces a property on its input. | PROP is one of the following | (sort KEYS) := force sort over list of KEYS | (limit LIMVAL OFFVAL) := force limit |
func | OP EXPRS... | Function | OP := symbol of the operator | EXPRS := 1 or more item operators |
mtable_ | (NAMESPACE SET? NELEMS . TYPES) MTABLE | Scan a memory table as if it were a real table. | NAMESPACE := valuespace where the columns appear | SET? := whether this is an ordered set, or just a bag of blobs | NELEMS := The number of elements in the mtable | TYPES := oidvs for types of the columns | MTABLE := item operator that provides the mtable blob |
mtable_ | (COLS) . EXPRS | Build a memory table. IN sets are sometimes converted to memory tables. | COLS := list of column names to use (in the 0 namespace) | EXPRS := list of (tuple () (param...) (param...) ...) | Denotes psuedo-mtable that should be built from previous constants. |
mtable_ | (NAMESPACE . TYPES) INPUT MTABLE EQUAL | Find a value in Memory table. | NAMESPACE := valuespace where the columns appear | TYPES := oidvs for types of the columns | INPUT := bulk input | MTABLE := item operator that provides the mtable blob | EQUAL := range denoting values to constrain in both low and high | (range equal ...) |
table_ | (RELOID LOCK) EXPR | Grabs one or more table locks for the duration of the subexpression. | RELOID := oid of table to lock | LOCK := Lock symbol | EXPR := row generator that is passed through |
table_ | NUMLOCKS EXPR | Placeholder for properly costing table locks. | NUMLOCKS := vs32 of the number of table locks to grab | EXPR := row generator |
pk_ | (NAMESPACE OID COLS LOCK) INPUT . PKREFS | Used to take fine grained locks | NAMESPACE := vs32 | OID := object ID of table | COLS := columns to bind | LOCK := Row lock symbol | INPUT := bulk operator | PKREFS := list of refs indicating primary key values to lock |
pk_ | (NAMESPACE RELOID REPOID COLS . PROPS) INPUT PKSARGE | Used to lookup which fine grained lock to take. | NAMESPACE := vs32 | RELOID := object ID of relation | REPOID := object ID of index | COLS := columns to bind/rebind | INPUT := bulk operator | PKSARGE := range denoting exact sarge on baserep |
table_ | (OID REFS . PROPS) INPUT_ | OID := object ID of table
| REFS := schema references containing values to use for each column
| PROPS := list of 0 or more of: ignore, replace, impdflt,
| serialize, multirow, lock_ |
table_ | (OID REFS) INPUT_ | OID := object ID of table
REFS := schema references containing values to use for each column
INPUT_
columns are taken from input row schema
|
table_ | (OID OLD_ | OID := object ID of table
OLD_
NEW_
PROPS := list of 0 or more of: ignore, serialize
INPUT_
|
Aggregate Operators
Aggregate Operators perform GROUP BY
and DISTINCT
operations.
Operator | Arguments | Details |
---|---|---|
aggregate | (KEY AGG_ | Logical operator, implemented as one of the physical aggregates |
hash_ | (KEY AGG_ | use a sigma, produces unsorted output |
sigma_ | (KEY AGG_ | use a sigma, produces output sorted on KEY |
stream_ | (KEY AGG_ | non-blocking, maintains incoming sort order (if any) |
dist_ | (KEY AGG_ | stream_ |
hash_ | (KEY AGG_ | hash_ |
hash_ | (KEY AGG_ | hash_ |
distinct | _ | Logical distinct operator, implemented as one of physical distinct operators. |
sigma_ | _ | produces output having only one row per distinct set of values for _ |
sigma_ | _ | does a sigma distinct on results from sigma_ |
sigma_ | _ | sigma_ |
sort | (KEY) INPUT_ | Logical sort operator. Force an ordering on the input. | KEY := list of (STYPE REF) | if STYPE := sort type (ASC, DSC, IFNULL) | REF := schema reference | else STYPE:= sort type GROUP | REF := list of schema references |
sigma_ | () INPUT_ | Force an ordering on the input using a sigma. Context has sort keys so don't show up in input always. |
Notation | Explanation |
---|---|
schema reference | (NAMESPACE . NAME) NAMESPACE: vs32 that represents which namespace (AUTOGEN = 0) NAME:string of the column name |
KEY | List of schema references to use as keys we are grouping by |
_ | keys to distinct by |
AGG_ | List of (NAME FUNC DISTINCT REF) |
NAME | For aggregates, this means new schema name for this value in the AUTOGEN (= 0) namespace |
FUNC | Aggregate function as a symbol (sum, max, min, count) |
DISTINCT | Does this aggregate function operate on distinct input? |
REF | Schema reference |
ONEOF | List of schema references to pass for aggregate oneof |
INPUT_ | Bulk operator providing rows |
LIMIT | (optional) item operator representing max # rows |
Join Operators
Join operators perform a left of nested loop join. Since joins are distributed, hash_
Operator | Format | Details |
---|---|---|
inner_ | STRAIGHT? INPUT1 INPUT2 . _ | Logical operator, implemented as a physical joins |
nljoin | ONE_ | Nested-loop join. Each row of INPUT1 is read and forwarded to correct next place for INPUT2 |
nljoin_ | ONE_ | Same as nljoin, differs in certain parallelization properties, primarily exists to make mechanics of optimizer work. |
left_ | STRAIGHT? INPUT1 INPUT2 . _ | STRAIGHT is always true, so INPUT1 is read before input 2. Also if there is no matching row in INPUT2, NULL value is substituted. |
left_ | (PROBEREF) INPUT1 INPUT2 . _ | Perform a left semi-join between INPUT1 and INPUT2, returning any rows from the left side for which the right side returns 1 or more |
item_ | JTYPE INPUT_ | item_ |
msjoin | ONE_ | Merge sort nested-loop join. This is similar to nljoin, but is able to preserve sort order. |
outer | () INPUT1 | Right half of a left outer join. |
outer_ | () INPUT1 [INPUT2] | Right half of a left outer join. This form of outer performs the outer calculation on a single node, which makes it much more efficient, but can only be applied in some cases. The optional INPUT2 bulk operator does not affect cardinality. |
dual | () | Generate a single row. |
Notation | Explanation |
---|---|
STRAIGHT | force reading the left relation before the right |
INPUT1 | bulk operator for the left side |
INPUT2 | bulk operator for the right side |
EXPR | 0 or more item operators representing join constraints |
PROBEREF | optional ref indicating whether the semi-join succeeded |
ONE_ | whether INPUT2 only has a cardinality of 1 or not |
JTYPE | is oneof
| (inner) - attach via inner_ |
Other Operators
These are the remaining operators, some are logical and some physical.
Operator | Format | Details |
---|---|---|
genoid | NAME INPUT_ | Create a unique id.
| NAME := name to assign a new oid
| INPUT_ |
lock_ | NUMLOCKS INPUT | Enforces either all row locks or all table locks for all reads in INPUT. | NUMLOCKS := vs32 of the number of locks to grab | INPUT := bulk operator for the rows to lock |
any | () BULK_ | BULK_
EXPR := test to apply for matches
|
check_ check_ | () INPUT_ REF INPUT_ | Errors out if input contains more than 1 row.
| INPUT_ |
compute | (NAMES TYPE) INPUT_ | NAMES := a list of new schema names for these values (in the AUTOGEN namespace)
TYPE := normal, fake, serialized
INPUT_
EXPRn := item operators for the expressions named in NAMES. Expressions (and names) are ordered from least dependant to most, so expressions later in the list can reference names defined earlier, but not vice-versa.
|
error | (RESULT_ | |
exists | () BULK_ | BULK_ |
ferel_ | (NS FEREL TYPE) | NS := namespace
FEREL := ferel (for column description)
TYPE := node type to create (t_
|
multi_ | ((NS1 NUMKEY . COLSET1) ...) INPUT | NS1 := namespace for first sigma
NUMKEY := colindex for # of keys to distinct on
COLSET1 := list of refs for first sigma
...
INPUT := bulk operator for row generator
|
parallel_ | () SOURCE . INPUT | SOURCE := bulk operator to apply INPUTs against
INPUT := 1 or more bulk operators that take SOURCE as input
|
read_ | (NS . COLS) | NS := namespace for sigmal
COLS := list of column names
|
tree_ | () INPUT_ | A special type of filter that pre-evaluates its expression(s), and then only executes the input if the expression(s) evaluates to true.
| This op thus requires that its expressions have no dependencies on the input.
| EXPR := item operator; null, 0, and false are filtered out
| INPUT_ |
tuple | () COL1... | COL1... := item operator expression for each column
Used to represent multicolumn comparisons (in, =, etc) |
union_ | (REFS1 REFS2 REFSOUT) INPUT_ | REFS1 := schema references used from INPUT_
REFS2 := schema references used from INPUT_
REFSOUT := schema references representing UNION display columns
INPUT_
INPUT_
|
var_ | (SCOPE NAME) VALUE | SCOPE := global/session/user
NAME := variable name
VALUE := value to assign variable to
|
var_ | (SCOPE NAME TYPE) | SCOPE := global/session/user
NAME := variable name
TYPE := oidtype of variable (only for user)
|