Repository navigation
Optimizer implementation
Implementation reference checked against f5e786f. Fundamental explanations remain in docs/arch.
- Plan construction and subquery lowering: build.cpp.
- Pass ordering and CTE phases: pipeline.cpp.
- Greedy/CBO selection and diagnostics: join_order.cpp.
- Bounded connected-subset search: dpccp.cpp.
- Predicate movement, equality extraction, outer-to-anti rewrite: equijoin.cpp.
- Estimates: estimate_stats.cpp.
- Shared definition/reuse: cte_reuse.cpp.
QDB_DUMP_PASSES=1 prints intermediate plans. --nocbo selects the heuristic
ordering path; --verbose also prints physical/runtime diagnostics.
QDB_DUMP_PASSES=1 ./build/bin/qdb --sql --data /path/to/parquet -i query.sql
./build/bin/qdb --sql --verbose --data /path/to/parquet -i query.sqlThe CBO component bound is NCbo::MaxRelations = 12. The region falls back
when CBO is disabled, an input lacks row statistics, an edge endpoint lacks a
positive NDV, there are no equality edges, a component exceeds the bound, or
search returns no tree. TPlanDiagnostics::JoinReorder records strategy and
reason. Disconnected CBO components are cross-joined in relation-count order.
Source-file navigation is maintained in the repository's AGENTS.md. Detailed examples formerly used to reproduce optimizer plans are retained below.
QDB_DUMP_PASSES=1 ./build/bin/qdb --sql --data <dir> -i q.sql # plan after every pass
./build/bin/qdb --sql --verbose --data <dir> -i q.sql # logical + runtime plan + scheduler graphAll examples below use four tiny Parquet tables:
| table | columns | rows |
|---|---|---|
t |
a int64, b string, c int64 |
6 |
u |
a int64, d string |
4 |
v |
a int64, e int64 |
3 |
big |
a int64, c int64 |
40 rows in 4 row groups |
Plans are printed by PrintPlanTree (qdb/plan/plan_print.cpp); source paths
are shortened here. rows≈/cost≈ annotations appear once EstimateStats has
run, and are elided below where they are not the point.