Step 5: Make Mark to Semi join conversion more stable by kryonix · Pull Request #23296 · duckdb/duckdb · GitHub
Skip to content

Step 5: Make Mark to Semi join conversion more stable - #23296

Merged
Mytherin merged 8 commits into
duckdb:mainfrom
kryonix:delim_join_as_cte_mark_to_semi
Jun 16, 2026
Merged

Mytherin merged 8 commits into
duckdb:mainfrom
kryonix:delim_join_as_cte_mark_to_semi

Conversation

@kryonix

@kryonix kryonix commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

In this PR, I try to make the full decorrelation cases more stable and robust, while allowing more cases. There were a few areas in the optimizer that prevented the system from finding good join types and/or join orders which can regress performance:

  • For correlated mark joins, convert_mark_to_semi was statically set to false. However, this was more of a guardrail to prevent the system from establishing semi-optimal join orders, because we were missing some heuristics in the build_probe_side optimizer for semi joins. This has been added now.
  • Decorrelated plans contain many ... IS NOT DISTINCT ... predicates. Problem is, this can prevent adding dynamic filters. pushdown_mark_join now tries to reduce them to regular equality predicates, if the join has been rewritten to a semi join.
  • The delim_cte_rewriter technically did the right thing for full decorrelation cases. However, it is not always desireable to fully decorrelate plans, instead of stopping early. This is a bit hard to decide without cost/cardinality information (maybe we should change that at some point). Therefore, it is a bit conservative when full decorrelation is used. Still, we allow it for more cases now (e. g. TPC-H Q21).

For TPC-H Q21, this PR improves performance by about 30-40%, for Q4 by about 25%, while avoiding to regress Q22 and Q17.

@kryonix
kryonix requested a review from lnkuiper June 16, 2026 08:25
@lnkuiper

Copy link
Copy Markdown
Member

@lnkuiper

lnkuiper commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Looks great, thanks!

EDIT: I can't add to the merge queue until CI is fixed, maybe @Mytherin can do that. I'll work on fixing CI :)

@Mytherin
Mytherin merged commit c0e6389 into duckdb:main Jun 16, 2026
50 of 52 checks passed
@Mytherin

Copy link
Copy Markdown
Member

Mytherin pushed a commit to Mytherin/duckdb that referenced this pull request Jun 16, 2026
Saw a flaky failure in duckdb#23296 hope
this fixes it
krlmlr pushed a commit to krlmlr/duckdb that referenced this pull request Jun 21, 2026
krlmlr pushed a commit to krlmlr/duckdb that referenced this pull request Jun 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants