Skip to main content

CustomOpCost

Struct CustomOpCost 

Source
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: u64

Cost 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: u64

Per-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: u64

Relate-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: bool

The 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: u8

Bit 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: u64

Per-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: u64

Rows 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

Source§

fn clone(&self) -> CustomOpCost

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CustomOpCost

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for CustomOpCost

Source§

fn eq(&self, other: &CustomOpCost) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for CustomOpCost

Source§

impl Eq for CustomOpCost

Source§

impl StructuralPartialEq for CustomOpCost

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,