Skip to content

Conversation

@JanKaul
Copy link
Contributor

@JanKaul JanKaul commented Oct 12, 2025

This is a draft PR to provide a basis for the discussion in issue #17719.

The main point of the PR is to get some experience for designing a JoinGraph structure. The PR pretends Datafusion already has a JoinGraph/QueryGraph implemented and tries to use its API for join order optimization.

It implements the closed form solution to calculating the optimal left-deep join tree developed by Ibaraki&Kameda: https://dl.acm.org/doi/pdf/10.1145/1270.1498
It is also presented here: https://youtu.be/CcUVvnYv7Hg?list=PLSE8ODhjZXjYCZfIbmEWH7f6MnYqyPwCE&t=1952

It can be used to obtain a reasonable join ordering in polynomial time or as a starting point for more sophisticated algorithms.

@github-actions github-actions bot added logical-expr Logical plan and expressions optimizer Optimizer rules catalog Related to the catalog crate labels Oct 12, 2025
Comment on lines +292 to +380
/// A simple Vec-based map that uses Option<T> for sparse storage
/// Keys are never reused once removed
pub(crate) struct VecMap<V>(Vec<Option<V>>);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if you heard about slab. It's the same as VecMap, but where you can reuse keys. However, I am unfamiliar with the process of pulling in external dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was using slotmap at first and also wasn't sure about the dependencies. And since we are not deleting notes, I thought the vecmap suffices.

And I mostly wanted to test the API of the query graph.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And since we are not deleting notes, I thought the vecmap suffices.

Aha okay, than i have nothing to add here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

catalog Related to the catalog crate logical-expr Logical plan and expressions optimizer Optimizer rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants