Documentation
¶
Overview ¶
Package weight turns a normalised engine plan into a verdict: OK, WARN or REFUSE. One cost model serves every engine:
- the tables of a group form one nested-loop pipeline, so the rows examined by the group are the product of their estimates;
- the child groups of a group (subqueries, derived tables, compound arms, the inner side of a hash join) add their cost, multiplied by the rows of the group's pipeline when they are correlated;
- REFUSE when the estimate exceeds explain_rows_refuse, when one full scan reads more than that, or on a cartesian join whose estimate is above explain_rows_warn;
- WARN when the estimate exceeds explain_rows_warn, on a full scan above it, on a sort or a temporary table above it, on a smaller cartesian join, on a recursive CTE (the engine marks it when its planner can only guess how often the recursion iterates: PostgreSQL, SQLite), and on a full scan of a table whose size the engine does not know (no statistics: the gate has no information on it).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Level ¶
type Level int
Level is the outcome of the weight check, ordered by severity.
func (Level) MarshalText ¶
MarshalText makes a Level show as "OK", "WARN" or "REFUSE" in JSON.
func (*Level) UnmarshalText ¶
UnmarshalText parses the names written by MarshalText.
type Verdict ¶
type Verdict struct {
Level Level `json:"level"`
// Reasons explains every finding that raised the level, most severe
// threshold first in the order found. It is empty for a plain OK.
Reasons []string `json:"reasons"`
// Summary is one line for the approval prompt: each table with its
// access and estimated rows, the sorts and temporary tables, and the
// estimate, e.g. "big full ~50 000 · sort · est. 50 000 rows examined".
Summary string `json:"summary"`
// EstimatedRows is the estimated number of rows examined, saturated at
// math.MaxInt64. Tables of unknown size count as one row.
EstimatedRows int64 `json:"estimated_rows"`
}
Verdict is the result of Assess.
Click to show internal directories.
Click to hide internal directories.