Cardinality Refinement Via Iterative Sampling In Duckdb
The document addresses the main weakness of traditional database optimization: the exponential error propagation that occurs when inaccurate initial cardinality estimates lead to wildly sub-optimal query plans. To resolve this structural vulnerability, the source proposes Iterative Sampling-Based Re-optimization (ISRO), a novel approach to Mid-Query Re-optimization within the DuckDB system. This feedback loop works by inserting a PhysicalSamplingOperator into the plan to perform controlled, partial execution and gather accurate, transient measurements of intermediate results. By feeding this refined cardinality data back into the Cost-Based Optimizer across several iterations, ISRO secures a stable, superior execution plan before full runtime, adhering to a necessary bounded overhead imperative.
