Skip to main content

Module pushdown

Module pushdown 

Source
Expand description

Predicate pushdown: translate Kit Expr predicates into MongrelDB core Conditions so the native engine can resolve them via indexes instead of a full-scan + Rust evaluation (Kit Priority 1).

§Design

The Kit’s query layer materializes every visible row and evaluates predicates in Rust. This module is the bridge that lets simple, index- served predicates bypass that full scan. It produces PushdownPlan — a list of native Conditions that the core engine can resolve via HOT / bitmap / range indexes, plus a flag indicating whether the translation covered the entire predicate.

Core’s native Query is a conjunction (AND of conditions) that resolves to a row-id set. Conditions always return a superset of the matching rows; the Kit must still re-apply the original Expr filter in Rust on the survivors unless PushdownPlan::fully_translated is true. This makes partial translation safe by construction.

§Supported translations

Kit ExprCore ConditionRequirement
Eq(Column, Literal) on PKPksingle-column PK
Eq(Column, Literal)BitmapEqbitmap-indexed column
In(Column, [literals])BitmapInbitmap-indexed column
Lt/Lte/Gt/Gte(Column, Literal) intRangeint-typed column
Lt/Lte/Gt/Gte(Column, Literal) floatRangeF64float-typed column
Contains(Column, needle)FmContainsFM-indexed column (residual re-check)
Like(Column, pattern)FmContainsAllFM-indexed column (residual re-check)
IsNull / IsNotNull(Column)IsNull / IsNotNullpage-stat-aware (residual re-check)
And([sub-exprs])recurse eacheach part translated independently

Unsupported (Or, Not, Ne, NotIn, InSubquery, Exists, cross-column comparisons) are left as residual Rust evaluation — the caller falls back to a full scan for those branches.

Structs§

PushdownPlan
The result of translating a Kit predicate into core conditions.

Functions§

pk_conditions
Build a Condition::Pk (or bitmap fallback) from a PK value map. Used by get_by_pk_internal and FK parent_exists — the highest-value pushdown targets since they currently do O(N) linear scans with the PK in hand.
translate_predicate
Attempt to translate expr into native Conditions for table. Returns None when no part of the expression could be translated (caller falls back to a full scan + Rust evaluation).