Documentation
¶
Overview ¶
Package plan reads PostgreSQL EXPLAIN output in JSON or text form.
Index ¶
Constants ¶
const ( High = "HIGH" Medium = "MEDIUM" Low = "LOW" )
Severity levels.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Comparison ¶
type Comparison struct {
BeforeMS float64 `json:"before_ms"`
AfterMS float64 `json:"after_ms"`
ChangePercent float64 `json:"change_percent"`
Fixed []Finding `json:"fixed"`
New []Finding `json:"new"`
Remaining []Finding `json:"remaining"`
Notes []string `json:"notes"`
}
Comparison shows what changed between two runs of a query.
func Compare ¶
func Compare(before, after *Plan) Comparison
Compare checks two plans of the same query, such as before and after adding an index.
type Finding ¶
type Finding struct {
ID string `json:"id"`
Severity string `json:"severity"`
Node string `json:"node"`
Message string `json:"message"`
Fix string `json:"fix"`
ImpactMS float64 `json:"impact_ms"`
}
Finding is one thing to look at. A plan shows symptoms, so fixes are candidates to test.
type Hot ¶
type Hot struct {
Node string `json:"node"`
SelfMS float64 `json:"self_ms"`
Percent float64 `json:"percent"`
}
Hot is a node and the time spent in it, leaving out its children.
type Node ¶
type Node struct {
Type string `json:"Node Type"`
Relation string `json:"Relation Name"`
Alias string `json:"Alias"`
Index string `json:"Index Name"`
Filter string `json:"Filter"`
PlanRows float64 `json:"Plan Rows"`
ActualRows float64 `json:"Actual Rows"`
Loops float64 `json:"Actual Loops"`
TotalTime float64 `json:"Actual Total Time"`
RemovedByFilter float64 `json:"Rows Removed by Filter"`
RemovedByJoin float64 `json:"Rows Removed by Join Filter"`
RemovedByCheck float64 `json:"Rows Removed by Index Recheck"`
SortMethod string `json:"Sort Method"`
SortSpaceType string `json:"Sort Space Type"`
SortSpaceKB float64 `json:"Sort Space Used"`
HashBatches float64 `json:"Hash Batches"`
PeakMemoryKB float64 `json:"Peak Memory Usage"`
WorkersPlanned float64 `json:"Workers Planned"`
WorkersLaunched float64 `json:"Workers Launched"`
HeapFetches float64 `json:"Heap Fetches"`
LossyBlocks float64 `json:"Lossy Heap Blocks"`
Children []*Node `json:"Plans"`
Analyzed bool `json:"-"`
}
Node is one step of a plan. Times, rows and removed rows are per loop, as Postgres reports them.
type Plan ¶
type Plan struct {
Root *Node
PlanningMS float64
ExecMS float64
JITMS float64
HasBuffers bool
Format string
}
Plan is one whole EXPLAIN result.