Skip to content

Use N-term telescoping for compiled inner joins - #8

Draft
ila wants to merge 7 commits into
mainfrom
codex/regular-nterm-inner-joins
Draft

Use N-term telescoping for compiled inner joins#8
ila wants to merge 7 commits into
mainfrom
codex/regular-nterm-inner-joins

Conversation

@ila

@ila ila commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an exact N-term telescoping strategy for compile-only, simple-projection inner joins over regular tables
  • reconstruct each old relation as R_old = R_now - delta_R, reducing an N-way join from 2^N - 1 delta terms to N terms
  • retain the existing inclusion-exclusion strategy for native refresh, outer joins, DuckLake, and unsupported leaf shapes
  • expose openivm_regular_nterm as a guarded setting and propagate it into compiled refresh planning

For a three-way join, the generated delta is:

delta_R JOIN S_old JOIN T_old
UNION ALL
R_now JOIN delta_S JOIN T_old
UNION ALL
R_now JOIN S_now JOIN delta_T

where each old-state input is reconstructed with signed multiplicities from the current table and its delta. This preserves exact Z-set semantics while avoiding the seven inclusion-exclusion terms otherwise required for three inputs.

Tests

  • make test — 55/55 suites, 7,538 assertions
  • focused join/compile suites — 475 assertions
  • mixed INSERT + UPDATE + DELETE self-join test with EXCEPT ALL bag-equality checks in both directions
  • TPC-DI SF1 rewriter benchmark — 45/45 incremental; 44/44 successful refreshes correct; only the pre-existing q40 ICU/collation binder failure
  • manual full-pipeline shape benchmark: fact_trade 15.52/16.79s to 10.22/10.33s; fact_holdings 22.45/18.79s to 12.30/15.19s

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant