pub struct JoinReorderer { /* private fields */ }Expand description
A cost-based join reorderer.
Holds a CostEstimator (a cheap Arc handle to a statistics
provider) and rewrites a QueryPlan’s join order to minimize
estimated cost. See the module docs for the algorithm and the
safety guarantees.
Implementations§
Source§impl JoinReorderer
impl JoinReorderer
Sourcepub fn new(stats_provider: Arc<dyn StatisticsProvider>) -> Self
pub fn new(stats_provider: Arc<dyn StatisticsProvider>) -> Self
Creates a reorderer backed by stats_provider.
Sourcepub fn with_cost_estimator(cost: CostEstimator) -> Self
pub fn with_cost_estimator(cost: CostEstimator) -> Self
Creates a reorderer that reuses an existing CostEstimator.
Sourcepub async fn reorder(&self, plan: &QueryPlan) -> Result<QueryPlan, VlorQLError>
pub async fn reorder(&self, plan: &QueryPlan) -> Result<QueryPlan, VlorQLError>
Returns a plan whose joins are reordered for minimal estimated
cost, or a clone of plan unchanged when reordering is unsafe or
would not reduce cost.
This is the primary entry point. It builds a JoinGraph, runs
the appropriate search (DP for ≤ MAX_DP_RELATIONS relations,
greedy otherwise), and only rewrites the plan when the new order
is both different and cheaper than the original.
Sourcepub async fn estimate_plan_cost(
&self,
plan: &QueryPlan,
) -> Result<Cost, VlorQLError>
pub async fn estimate_plan_cost( &self, plan: &QueryPlan, ) -> Result<Cost, VlorQLError>
Estimates the cost of executing plan’s join chain in the order
it is written.
For a plan with no reorderable join graph this is just the cost of
scanning the from relation. Useful for asserting that a
reordered plan is cheaper than the original.
Trait Implementations§
Source§impl Clone for JoinReorderer
impl Clone for JoinReorderer
Source§fn clone(&self) -> JoinReorderer
fn clone(&self) -> JoinReorderer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for JoinReorderer
impl !UnwindSafe for JoinReorderer
impl Freeze for JoinReorderer
impl Send for JoinReorderer
impl Sync for JoinReorderer
impl Unpin for JoinReorderer
impl UnsafeUnpin for JoinReorderer
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request