Repository navigation
Conversation
… proven `DELETE FROM t ROWS (q)` retracts `t INTERSECT ALL q`, which reads and arranges all of `t`. When `q` is provably a sub-multiset of `t` at every timestamp, the intersection equals `q`, so the write can retract `q` directly and read only the collections `q` reads, for example a small materialized view of garbage rows. A new `SubMultiset` analysis in `mz-transform` proves containment conservatively over filters, identity projections, `EXCEPT ALL` and `INTERSECT ALL` shapes, and `Let` bindings. The adapter seeds it from the catalog: views and materialized views without a refresh schedule or replacement history count when their definitions are proven contained in the target table version. Anything else keeps the intersection. `mz_delete_rows_selection_total` counts which selection ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Local optimization pushes `Negate` below `Map` and `Project`, so the subtracted input of a planned `EXCEPT ALL` need not be a `Negate`. The intersection rule also proves `A INTERSECT ALL B` from `A` alone for any subtracted input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
antiguru
force-pushed
the
delete-rows-containment
branch
from
October 21, 2026 09:34
d6325a2 to
373bb46
Compare
This branch has not been deployed
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.
Based on #40052.
DELETE FROM t ROWS (q)writesNegate(q)instead ofNegate(t INTERSECT ALL q)when it can prove thatqis a sub-multiset oft. The selection then reads onlyq, for example a small materialized view of rows due for cleanup, instead of scanning and arranging all oft.A new
SubMultisetMIR analysis inmz-transformdoes the proof. The adapter feeds it facts from the catalog: views by their definition, and materialized views only without a refresh schedule or replacement history. Unknown shapes fall back to the intersection. The OCC write atTlands only if the table is unchanged sinceT-1, so the proof holds at write time. The countermz_delete_rows_selection_totalrecords which path ran.🤖 Generated with Claude Code