pub struct CustomOpCost {
pub drain_rows: u64,
pub per_key_unit: u64,
pub inline_point_unit: u64,
pub direct_probe: bool,
pub probe_keyed_columns: u8,
pub probe_filter_unit: u64,
pub probe_memo_entry_rows: u64,
}Expand description
Explicit execution-cost model for one plugin op (CustomOp::cost).
produced_row_count_estimate does double duty today: cardinality for
join math AND a stand-in execution cost. That conflation is wrong for
ops whose work does not scale with their OUTPUT — the geo scan’s keyless
(driver-side) sweep drains and relates a whole window regardless of how
few rows it emits, and its keyed (probe-side) regime is whatever the
executor’s roads make it: a direct per-key decision when the op has one
(direct_probe), otherwise one drain plus a filter over the drain’s
output. This struct names the inputs of those regime formulas; the
formulas live on CustomOp (sweep_cost, probe_page_cost,
probe_drain_amortized, keyed_cost) as the CONSERVATIVE PLANNER BOUND
of the executor’s break-even: every key prices at per_key_unit because
the planner knows value COUNTS, never key SHAPES, so a point-heavy mix
prices higher here than the executor’s shape-aware road choice.
The probe fields exist because the two old roads were not enough for
index-scan ops. A text text:query drain is driven by the QUERY, not by
the pushed keys, so its work is the same for a one-key list and a
million-key list, and its executor has no direct road at all. Pricing
such an op as min(direct, drain + survivors × unit) made it look
cheap on the probe side and pushed the plan into per-page re-drains.
direct_probe = false removes the invented road;
probe_keyed_columns names which output columns are answered by a keyed
lookup — a pushed key in an unkeyed column (the text subject resolve’s
graph column) still scans the whole drain output — and
probe_memo_entry_rows says whether the drain can be paid ONCE (the
op’s window fits its drain memo) or must be charged on every page.
Consumed by the seating-cost model: the custom driver’s work prices
CustomOp::sweep_cost via seat_driver_work_rows, and the custom
probe branch of seat_cost_total prices probe_page_cost per page plus
the drain once-or-per-page; EXPLAIN renders the drain/unit stamp.
Units are the seating-cost model’s rows currency: one unit ≈ the work of
reading one row. Partition-side index walks and per-term CPU work both
map onto it; custom ops carry no index seeks, so they price at zero
seeks. An op with cost: None (every construction site that has not
opted in) prices opaquely at its row estimate — the pre-cost-model
behavior, unchanged.
Fields§
§drain_rows: u64Cost of the op’s candidate drain WHEN the execution runs one: the keyless regime always drains; the keyed regime drains only when it takes the semi-join road instead of relating the pushed values directly. The partition-side walk + dedup over the op’s index ranges, priced in rows.
per_key_unit: u64Per-term relate work for a BLOB-BACKED term: one pushed value in the keyed regime, one candidate in the keyless regime’s relate loop — blob fetch (amortized), parse, and exact relate. One conservative unit per op; term-mix refinement is the consumer’s option, not the model’s.
inline_point_unit: u64Relate-only work of an INLINE term: a LiteralPoint relates from
its stored coordinates with no blob fetch and no parse. The
EXECUTOR classifies the actual pushed values by term shape and prices
the direct road per key with this unit; the plan-side probe price
keeps the conservative all-blob bound because the planner knows key
COUNTS, never key SHAPES.
direct_probe: boolThe op can decide one pushed key locally, without draining. Geo and the text prefix/suffix modes have this road; text FTS and the text subject resolve do not (their candidate set comes from the index query, and a pushed literal/subject cannot be answered by a local test).
probe_keyed_columns: u8Bit i set: output variable i is answered by a KEYED lookup, so a
probe page on that column examines min(pushed, produced) and pays
pushed × probe_filter_unit. Bit clear, or no known pushed column:
the page filters the WHOLE drain output (produced).
Single-column ops use 0 for a scan filter (the literal-mode
candidate scan) and 1 for a keyed decision (geo, the subject
resolve). The subject resolve’s two-column shape is 0b1: the
memoized window is sorted by (subject, graph), so a pushed subject
is a binary search while a pushed GRAPH still scans the window.
probe_filter_unit: u64Per-row work of a probe page’s filter over the drain output. For an op that filters the drain’s rows this is the per-row compare cost; for one that indexes the drain output by key it would be the lookup cost instead.
probe_memo_entry_rows: u64Rows the op’s drain-window memo can admit (0 = never amortized).
When produced <= probe_memo_entry_rows the cost model charges the drain
ONCE and only the filter per page; otherwise the drain is charged on
every page — the honest price for a window the memo will refuse and
the executor will re-drain.
Trait Implementations§
Source§impl Clone for CustomOpCost
impl Clone for CustomOpCost
Source§fn clone(&self) -> CustomOpCost
fn clone(&self) -> CustomOpCost
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CustomOpCost
impl Debug for CustomOpCost
Source§impl PartialEq for CustomOpCost
impl PartialEq for CustomOpCost
impl Copy for CustomOpCost
impl Eq for CustomOpCost
impl StructuralPartialEq for CustomOpCost
Auto Trait Implementations§
impl Freeze for CustomOpCost
impl RefUnwindSafe for CustomOpCost
impl Send for CustomOpCost
impl Sync for CustomOpCost
impl Unpin for CustomOpCost
impl UnsafeUnpin for CustomOpCost
impl UnwindSafe for CustomOpCost
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].