Documentation ¶
Index ¶
- type Agg
- type Append
- type BadNode
- type BitmapAnd
- type BitmapHeapScan
- type BitmapIndexScan
- type BitmapOr
- type CteScan
- type CustomScan
- type ForeignScan
- type FunctionScan
- type Gather
- type GatherMerge
- type Group
- type Hash
- type HashJoin
- type IncrementalSort
- type IndexOnlyScan
- type IndexScan
- type Join
- type Limit
- type LockRows
- type Material
- type MergeAppend
- type MergeJoin
- type ModifyTable
- type NamedTuplestoreScan
- type NestLoop
- type Node
- type NodeKind
- type Operation
- type ParentRelationship
- type Plan
- type ProjectSet
- type RecursiveUnion
- type Result
- type SampleScan
- type Scan
- type SeqScan
- type SetOp
- type Sort
- type Strategy
- type SubqueryScan
- type TableFuncScan
- type TidScan
- type Unique
- type ValuesScan
- type WindowAgg
- type WorkTableScan
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Append ¶
type Append struct{ Plan }
Append is the concatenation of the results of sub-plans. Combine the results of the child operations. This can be the result of an explicit UNION ALL statement, or the need for a parent operation to consume the results of two or more children together. https://www.pgmustard.com/docs/explain/append
type BitmapHeapScan ¶
type BitmapHeapScan struct{ Plan }
func (BitmapHeapScan) Kind ¶
func (BitmapHeapScan) Kind() NodeKind
type BitmapIndexScan ¶
type BitmapIndexScan struct{ Plan }
func (BitmapIndexScan) Kind ¶
func (BitmapIndexScan) Kind() NodeKind
type CustomScan ¶
type CustomScan struct{ Plan }
func (CustomScan) Kind ¶
func (CustomScan) Kind() NodeKind
type ForeignScan ¶
type ForeignScan struct{ Plan }
func (ForeignScan) Kind ¶
func (ForeignScan) Kind() NodeKind
type FunctionScan ¶
type FunctionScan struct{ Plan }
func (FunctionScan) Kind ¶
func (FunctionScan) Kind() NodeKind
type GatherMerge ¶
type GatherMerge struct{ Plan }
func (GatherMerge) Kind ¶
func (GatherMerge) Kind() NodeKind
type IncrementalSort ¶
type IncrementalSort struct{ Plan }
func (IncrementalSort) Kind ¶
func (IncrementalSort) Kind() NodeKind
type IndexOnlyScan ¶
type IndexOnlyScan struct{ Plan }
func (IndexOnlyScan) Kind ¶
func (IndexOnlyScan) Kind() NodeKind
type MergeAppend ¶
MergeAppend combines the sorted results of the child operations, in a way that preserves their sort order. Can be used for combining already-sorted rows from table partitions. https://www.pgmustard.com/docs/explain/merge-append
func (MergeAppend) Kind ¶
func (MergeAppend) Kind() NodeKind
type ModifyTable ¶
ModifyTable applies rows produced by subplan(s) to result table(s), by inserting, updating, or deleting.
func (ModifyTable) Kind ¶
func (ModifyTable) Kind() NodeKind
type NamedTuplestoreScan ¶
type NamedTuplestoreScan struct{ Plan }
func (NamedTuplestoreScan) Kind ¶
func (NamedTuplestoreScan) Kind() NodeKind
type Node ¶
type Node interface { Kind() NodeKind // Output returns the output columns of the node. The format of each output // column depends on the type of node. Output() []string // Children returns the direct children of the node, or nil if none exist. Children() []Node }
Node is the super-type of all Postgres plan nodes. https://doxygen.postgresql.org/nodes_8h.html#a83ba1e84fa23f6619c3d29036b160919
func ExplainQuery ¶
ExplainQuery executes an explain query and parses the plan.
type NodeKind ¶
type NodeKind string
NodeKind is the top-level node plan type that Postgres plans for executing query. https://www.postgresql.org/docs/13/executor.html
const ( KindBadNode NodeKind = "BadNode" KindResult NodeKind = "Result" KindProjectSet NodeKind = "ProjectSet" KindModifyTable NodeKind = "ModifyTable" KindAppend NodeKind = "Append" KindMergeAppend NodeKind = "MergeAppend" KindRecursiveUnion NodeKind = "RecursiveUnion" KindBitmapAnd NodeKind = "BitmapAnd" KindBitmapOr NodeKind = "BitmapOr" KindScan NodeKind = "Scan" KindSeqScan NodeKind = "SeqScan" KindSampleScan NodeKind = "SampleScan" KindIndexScan NodeKind = "IndexScan" KindIndexOnlyScan NodeKind = "IndexOnlyScan" KindBitmapIndexScan NodeKind = "BitmapIndexScan" KindBitmapHeapScan NodeKind = "BitmapHeapScan" KindTidScan NodeKind = "TidScan" KindSubqueryScan NodeKind = "SubqueryScan" KindFunctionScan NodeKind = "FunctionScan" KindValuesScan NodeKind = "ValuesScan" KindTableFuncScan NodeKind = "TableFuncScan" KindCteScan NodeKind = "CteScan" KindNamedTuplestoreScan NodeKind = "NamedTuplestoreScan" KindWorkTableScan NodeKind = "WorkTableScan" KindForeignScan NodeKind = "ForeignScan" KindCustomScan NodeKind = "CustomScan" KindJoin NodeKind = "Join" KindNestLoop NodeKind = "NestLoop" KindMergeJoin NodeKind = "MergeJoin" KindHashJoin NodeKind = "HashJoin" KindMaterial NodeKind = "Material" KindSort NodeKind = "Sort" KindIncrementalSort NodeKind = "IncrementalSort" KindGroup NodeKind = "Group" KindAgg NodeKind = "Agg" KindWindowAgg NodeKind = "WindowAgg" KindUnique NodeKind = "Unique" KindGather NodeKind = "Gather" KindGatherMerge NodeKind = "GatherMerge" KindHash NodeKind = "Hash" KindSetOp NodeKind = "SetOp" KindLockRows NodeKind = "LockRows" KindLimit NodeKind = "Limit" )
type ParentRelationship ¶
type ParentRelationship string
ParentRelationship describes why this operation needs to be run in order to facilitate the parent operation.
const ( // ParentRelationshipNone means this node is a top-level node. All nodes with // a parent have set relationship that is not none. ParentRelationshipNone ParentRelationship = "" // ParentRelationshipOuter is the most common node. It means take in the rows // from this operation as input, process them and pass them on. ParentRelationshipOuter ParentRelationship = "Outer" // ParentRelationshipInner is only (but always) on second child of join // operations. Means a node is the inner part of a loop. ParentRelationshipInner ParentRelationship = "Inner" // ParentRelationshipMember is for all children of Append and ModifyTable // nodes. ParentRelationshipMember ParentRelationship = "Member" // ParentRelationshipInitPlan is calculations performed before query starts // executing. ParentRelationshipInitPlan ParentRelationship = "InitPlan" // ParentRelationshipSubquery means the node is a subquery of a parent node. // Since Postgres always uses subquery scans to feed subquery data to parent // queries, only ever appears on the children of subquery scans. ParentRelationshipSubquery ParentRelationship = "Subquery" // ParentRelationshipSubPlan is like a Subquery, represents a new query, but // used when a subquery scan is not necessary. ParentRelationshipSubPlan ParentRelationship = "SubPlan" )
type Plan ¶
type Plan struct { // Estimated execution costs for plan (see costsize.c for more info). StartupCost float64 // cost expended before fetching any tuples TotalCost float64 // total cost (assuming all tuples fetched) // Planner's estimate of result size of this plan step. PlanRows float64 // number of rows plan is expected to emit PlanWidth int // average row width in bytes // Information needed for parallel query. ParallelAware bool // engage parallel-aware logic? ParallelSafe bool // OK to use as part of parallel plan? // Relationship from this node to its parent. Always set for descendant nodes. ParentRelationship ParentRelationship // How to execute a node. Used for Agg and SetOp nodes. Strategy Strategy // Custom plan, if any. CustomPlanProvider string // The column expressions (target list), if any. Outs []string // Child nodes, if any. Nodes []Node }
Plan nodes "derive" from the Plan structure by having the Plan structure as the first field. This ensures that everything works when nodes are cast to Plan's. (node pointers are frequently cast to Plan* when passed around generically in the executor) https://sourcegraph.com/github.com/postgres/postgres@8facf1ea00b7a0c08c755a0392212b83e04ae28a/-/blob/src/include/nodes/plannodes.h#L110:16
type ProjectSet ¶
type ProjectSet struct{ Plan }
ProjectSet appears when the SELECT or ORDER BY clause of the query. They basically just execute the set-returning function(s) for each tuple until none of the functions return any more records. https://www.postgresql.org/message-id/CAKJS1f9pWUwxaD%2B0kxOOUuwaBcpGQtCKi3DKE8ob_uHN-JTJhw%40mail.gmail.com
func (ProjectSet) Kind ¶
func (ProjectSet) Kind() NodeKind
type RecursiveUnion ¶
type RecursiveUnion struct{ Plan }
func (RecursiveUnion) Kind ¶
func (RecursiveUnion) Kind() NodeKind
type Result ¶
type Result struct{ Plan }
Result is if no outer plan, evaluate a variable-free targetlist. If outer plan, return tuples from outer plan (after a level of projection as shown by targetlist). https://sourcegraph.com/github.com/postgres/postgres@8facf1ea00b7a0c08c755a0392212b83e04ae28a/-/blob/src/include/nodes/plannodes.h#L180:1
type SampleScan ¶
type SampleScan struct{ Plan }
func (SampleScan) Kind ¶
func (SampleScan) Kind() NodeKind
type Strategy ¶
type Strategy string
Strategy determines overall execution strategies for Agg plan nodes and SetOp nodes. https://source graph.com/github.com/postgres/postgres@8facf1ea00b7a0c08c755a0392212b83e04ae28a/-/blob/src/include/nodes/nodes.h?subtree=true#L759:14
const ( // StrategyPlain is a simple agg across all input rows. StrategyPlain Strategy = "Plain" // StrategySorted is a for grouped agg and SetOp, input must be sorted. StrategySorted Strategy = "Sorted" // StrategyHashed is a for grouped agg and SetOp, uses internal hashtable. StrategyHashed Strategy = "Hashed" // StrategyMixed is a grouped agg, hash and sort both used. StrategyMixed Strategy = "Mixed" // StrategyUnknown is a for unknown aggregates. StrategyUnknown Strategy = "???" )
type SubqueryScan ¶
type SubqueryScan struct{ Plan }
func (SubqueryScan) Kind ¶
func (SubqueryScan) Kind() NodeKind
type TableFuncScan ¶
type TableFuncScan struct{ Plan }
func (TableFuncScan) Kind ¶
func (TableFuncScan) Kind() NodeKind
type Unique ¶
type Unique struct{ Plan }
Unique is a very simple node type that just filters out duplicate tuples from a stream of sorted tuples from its subplan. https://sourcegraph.com/github.com/postgres/postgres@8facf1ea00b7a0c08c755a0392212b83e04ae28a/-/blob/src/include/nodes/plannodes.h?subtree=true#L864:16
type ValuesScan ¶
type ValuesScan struct{ Plan }
func (ValuesScan) Kind ¶
func (ValuesScan) Kind() NodeKind
type WorkTableScan ¶
type WorkTableScan struct{ Plan }
func (WorkTableScan) Kind ¶
func (WorkTableScan) Kind() NodeKind