Repository navigation
Add the DPsub join-order enumeration algorithm - #107351
Conversation
|
Workflow [PR], commit [cfd9646] Summary: ✅
AI ReviewSummaryThis PR adds the opt-in Missing context / blind spots
Findings❌ Blockers
Tests
Final VerdictStatus: Minimum required actions: fix the dropped-predicate correctness issue, add a safe |
a8367d1 to
fd0b982
Compare
…n exception 'Cannot fold actions for projection', thus required more investigation
fd0b982 to
c5145d1
Compare
… Also changed the history values so that the new algorithm gets invoked in the tests
ahmadov
left a comment
There was a problem hiding this comment.
in general, LGTM 👍
I'd consider only fixed 50'000 and memory allocation before checking max_num_ccp a blocker to merge, otherwise it's in a good shape.
|
|
||
| bool isConnected(TUInt S) const { return table[S].count; } | ||
| size_t numRelations() const { return num_relations; } | ||
| UInt64 noCcp() const { return nr_ccp; } |
There was a problem hiding this comment.
I guess both noCcp() and nr_ccp should use the same name. Maybe numCcp or numCCP?
There was a problem hiding this comment.
I'm using snake_case for variables this way we're coherent with the style guide and the rest of the code in our code base. I will change however noCcp to noCCP.
There was a problem hiding this comment.
ah sorry for confusion, I meant numCCP() for the function and num_ccp for the variable. But it's fine with the current state.
| UInt64 noCsg() const { return map().size(); } | ||
| const Map & map() const { return table; } | ||
|
|
||
| void printStatistics() const; |
There was a problem hiding this comment.
no caller for printStatistics, just remove it?
There was a problem hiding this comment.
these are actually quite useful. We need such stats for debugging as well as for comparison over enumeration space explored by different enumeration algorithms. Further, using such stats one can easily measure the efficiency of an algorithm (vs. elapsed time).
There was a problem hiding this comment.
What about printing that statistics behind a settings named something like dpsub_print_statistics / print_join_enumeration_statistics (require implementation for all algorithms)? That way we can get the statistics from the running server. Would that make sense? It's up to you
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 308/332 (92.77%) · Uncovered code |
…anch Add the DPsub join-order enumeration algorithm
Changelog category (leave one):
Motivation
The cost-based join-order optimizer currently offers two enumeration strategies,
selectable via query_plan_optimize_join_order_algorithm: greedy (fast but
often suboptimal) and
dpsize(optimal but comparatively expensive). This PRintroduces a third option,
dpsub, which produces the same optimal plans asdpsizewhile significantly reducing optimization time.Across chain, star, clique, and cyclic join graphs,
dpsubconsistentlyoutperforms
dpsize, despite enumerating more CCPs in some cases. Theperformance gain comes from a more efficient implementation and reduced
enumeration overhead.
In addition,
dpsubsupports both inner and non-inner joins, whereasdpsizecan only optimize join orders for inner joins.
The implementation is highly modular and template-based, allowing its
components to serve as building blocks for future work, including
dphyp.The enumerator has been factored into a standalone component (joinEnum.h),
while the DP table and bookkeeping logic have been separated into reusable
structures, with enumChecker.h handling plan acceptance, cost, and
cardinality tracking.
Results
Optimization time for queries with 5 relations across several join-graph
topologies (measured on an M5 MacBook Max). All three algorithms produce the
same final plan, while greedy may select lower-quality execution plans.
dpsubmatches the plan quality ofdpsize.Optimization time for queries with 10 relations:
dpsuboutperformsdpsizeacross all tested topologies while producingidentical optimal plans. Improvement is most pronounced on sparse graphs
(chain, star, cycle) at 5–20×.
The following benchmarks were run after PR #98798 was merged into master.
That merge also brought improvements to
dpsize.Across all topologies and both relation counts,
dpsubyields thelowest optimization time among the DP algorithms.
Optimization time for queries with 5 relations:
Optimization time for queries with 10 relations:
Changelog entry
Added the dpsub join-order enumeration algorithm, providing optimal join
plans with lower optimization overhead than dpsize and support for non-inner
joins.
Version info
26.7.1.344(included in26.7and later)