Skip to main content

ScalarPkProbeFastPath

Struct ScalarPkProbeFastPath 

Source
pub struct ScalarPkProbeFastPath {
    pub outer_pos: usize,
    pub inner_table_name: String,
    pub inner_pos: usize,
    pub table_idx: usize,
}
Expand description

v7.32 (R30 memory) — cheap static correlation pre-check.

subquery_replacement distinguishes a correlated subquery from an uncorrelated one by optimistically executing it and catching the resulting ColumnNotFound / UnknownQualifier. For a join-bodied correlated subquery that catch fires only AFTER the inner FROM is materialised — and the deferred-join pipeline clones the whole driving table to do it (the inbox … JOIN messages m2 … body clones 960k × 10 KB ≈ 10 GB at prod scale, once per outer query, purely to be thrown away). A correlated subquery is always handled downstream by the per-row / post-LIMIT correlated path, so spotting it up front lets us skip the wasted materialisation entirely.

Sound for the true answer: returns true only when a qualified column at the statement’s own level names a qualifier that is not one of its own FROM aliases — exactly the reference the inner exec would fail to resolve. Everything it can’t reason about cleanly (lateral / derived FROM entries) returns false and falls through to the existing execute-and-catch path, so behaviour is unchanged. v7.37.x (docker-fair SCALARSQ attack) — pre-analysed plan for the (SELECT COUNT(*) FROM T WHERE T.pk = outer.col) correlated scalar subquery shape. Computing the table + index + position lookups once per query (instead of once per outer row) drops the per-row work to a single column read + index probe.

Fields§

§outer_pos: usize

Position in the OUTER scan schema for the column that drives the equality. Per row we read row.values[outer_pos] directly.

§inner_table_name: String

Catalog-qualified name of the inner table (looked up per probe).

§inner_pos: usize

Column position of the inner-side PK on which we probe.

§table_idx: usize

v7.37.42 (docker-fair SCALARSQ attack 1) — cached insertion-order index of inner_table_name in the active catalog at PREPARE time. The executor and prepare share a single engine RwLock read guard per query (see pgwire.rs simple-query path), so the catalog can’t mutate mid-query — the cached index stays in sync with the string name. The per-row probe therefore skips the BTreeMap<String, usize> descent that Catalog::get(&str) would otherwise perform, saving ~300 ns × N outer rows.

Implementations§

Source§

impl ScalarPkProbeFastPath

Source

pub fn probe(&self, row: &Row<'static>) -> Value<'static>

Per-row probe. Reads row.values[self.outer_pos], looks up the inner table and PK index, and returns Int(1) on a hit or Int(0) on a miss / NULL outer key.

Trait Implementations§

Source§

impl Clone for ScalarPkProbeFastPath

Source§

fn clone(&self) -> ScalarPkProbeFastPath

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ScalarPkProbeFastPath

Source§

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

Formats the value using the given formatter. Read more

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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.