Optimize planner stats and functional recursive joins#574
Merged
Conversation
6e009e6 to
df5954d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds generic planner stats support for relationship cardinality estimates, an explicit
ANALYZEcommand to refresh planner stats, and a guarded recursive-join fast path for functional chains.The functional-chain recursive join fast path applies to a narrow, generic case:
*min..max)When those conditions hold, the relationship graph is a set of chains or cycles where every node has zero or one next node. Instead of running the full recursive graph-search machinery, the operator first builds a
nextOffsetsarray:If it sees two outgoing neighbors for any node, it bails out and uses the normal recursive implementation.
Once the array is built, each source node is handled by pointer chasing:
It emits
(src, dst, length)rows for lengths in the requested recursive range, respectinglowerBound,upperBound, input/output masks, visibility, and limit counters.Why this is faster: the normal recursive machinery has to manage frontier expansion, graph scans, path semantics, intermediate state, and generalized output handling. For a functional chain, there is no branching, so the next hop is just an array lookup per step. That turns recursive expansion into tight linear pointer chasing while preserving the same result shape for the guarded case.
Validation
cmake --build build/release --target lbug_shell -j 8/tmp/bb_full_hash_off_fwd_art.lbugin read-only modeANALYZE;andANALYZE Event;against/tmp/bb_full_hash_off_fwd_art.lbugin read-only mode