pub struct OperatorFeedback {
pub operator_id: String,
pub operator_type: String,
pub estimated_rows: u64,
pub actual_rows: u64,
pub actual_input_rows: Option<u64>,
pub partition_count: u32,
pub exhausted: bool,
pub estimated_time_us: u64,
pub actual_time_us: u64,
pub execution_loops: u64,
pub condition_key: Option<String>,
pub shape_key: Option<String>,
}Expand description
Operator execution feedback
Records statistical information about the execution of individual operators. Refer to the output format of EXPLAIN ANALYZE in PostgreSQL.
§Field Description
operator_id: The unique identifier for the operator.
operator_type: The type of the operator (such as Scan, Filter, Join, etc.)
estimated_rows: The number of output rows estimated by the optimizer.
actual_rows: The actual number of rows output.
estimated_time_us: Estimated execution time (in microseconds)
actual_time_us: Actual execution time (in microseconds)
execution_loops: The number of executions (for example, the number of times the inner loop of a Nested Loop is executed).
§Example
use linkrs_query::optimizer::stats::feedback::query::OperatorFeedback;
let feedback = OperatorFeedback {
operator_id: "scan_1".to_string(),
operator_type: "IndexScan".to_string(),
estimated_rows: 100,
actual_rows: 150,
actual_input_rows: None,
partition_count: 1,
exhausted: true,
estimated_time_us: 1000,
actual_time_us: 1200,
execution_loops: 1,
condition_key: None,
shape_key: None,
};
assert_eq!(feedback.row_estimation_error(), 0.5); // (150-100)/100Fields§
§operator_id: StringOperator ID
operator_type: StringOperator types
estimated_rows: u64Estimated number of output lines
actual_rows: u64Number of actual lines of output
actual_input_rows: Option<u64>Actual input rows consumed by this operator, summed across
partitions. Lets the fold loop isolate the operator-local
parameter (e.g. observed selectivity) from upstream cardinality
error. None means unmeasured: the sample cannot separate
predicate error and must not train selectivity.
partition_count: u32How many partition instances this sample aggregates. Always >= 1; greater than 1 means per-partition profiles were summed into one per-execution sample before any correction was computed.
exhausted: boolWhether every aggregated instance ran to exhaustion. Samples from starved operators (Limit / early termination) carry partial counts and must not train the feedback loop.
estimated_time_us: u64Estimated execution time (in microseconds)
actual_time_us: u64Actual execution time (in microseconds)
execution_loops: u64Number of executions (for example, the number of times the inner loop of a nested loop is executed)
condition_key: Option<String>Normalized predicate key for filter operators.
Populated only for operators whose spec carries a predicate (e.g.
UnarySpec::Filter); used by the statistics feedback loop
to attach estimated-vs-actual row ratios to a specific predicate.
shape_key: Option<String>Normalized operator shape key ("{space}:{Type}:{discriminator}").
Populated for operators whose output cardinality is estimated
independently (scans, graph traversals, joins, applies); used by the
cardinality feedback loop to correct per-shape row estimates. Filter
operators are keyed by condition_key instead and leave this None.
Implementations§
Source§impl OperatorFeedback
impl OperatorFeedback
Sourcepub fn new(
operator_id: String,
operator_type: String,
estimated_rows: u64,
actual_rows: u64,
) -> Self
pub fn new( operator_id: String, operator_type: String, estimated_rows: u64, actual_rows: u64, ) -> Self
Create new operator feedback.
Sourcepub fn row_estimation_error(&self) -> f64
pub fn row_estimation_error(&self) -> f64
Estimation error of the number of lines calculated
Return the relative error: (Actual – Estimated) / Estimated If the estimate is 0, return 1.0
Sourcepub fn time_estimation_error(&self) -> f64
pub fn time_estimation_error(&self) -> f64
Calculating the estimated error in time measurement
Return relative error: (actual-estimate)/estimate
Sourcepub fn avg_rows_per_loop(&self) -> f64
pub fn avg_rows_per_loop(&self) -> f64
Obtain the average number of actual rows executed in each case.
For operators that are executed multiple times (such as the inner loop in a Nested Loop), Return the average number of lines executed per run.
Sourcepub fn avg_time_us_per_loop(&self) -> f64
pub fn avg_time_us_per_loop(&self) -> f64
Obtain the average actual time (in microseconds) for each execution.
Trait Implementations§
Source§impl Clone for OperatorFeedback
impl Clone for OperatorFeedback
Auto Trait Implementations§
impl Freeze for OperatorFeedback
impl RefUnwindSafe for OperatorFeedback
impl Send for OperatorFeedback
impl Sync for OperatorFeedback
impl Unpin for OperatorFeedback
impl UnsafeUnpin for OperatorFeedback
impl UnwindSafe for OperatorFeedback
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.