Repository navigation
The typed source cleanup builds the set of sources that still hold once, so a large base's cleanup no longer rescans the binding match per source - #1490
Merged
WaylandYang merged 2 commits intoNov 10, 2026
Conversation
…ce, so a large base's cleanup no longer rescans the binding match per source Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
WaylandYang
approved these changes
Nov 10, 2026
WaylandYang
left a comment
Contributor
There was a problem hiding this comment.
Thanks, the rewrite is equivalent to the old query. Merging. Not blocking: when you next have the big base, could you post the DELETE plan itself (EXPLAIN, expecting a hash anti join)? The test proves the CTE exists, not that the plan is fast.
gedaiu
added a commit
to re-cinq/utopia
that referenced
this pull request
Nov 10, 2026
Sync upstream dev into re-dev (2026-11-10): deeplethe#1487, deeplethe#1488, deeplethe#1490, deeplethe#1491
Contributor
Author
|
Here is the plan you asked for, from our largest base (922k rows in One honest caveat. This base has not run migration 0121 yet, so the mood check inside EXPLAINThank you again for the quick merge. |
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.
Closes #1483
The first step of the typed-source cleanup in
materializewas a correlatedNOT EXISTSover the binding match. On a base with about 690k typed sources the planner estimated one row for that match and rescanned it for every source, so the delete ran for roughly twelve hours. This PR collects the sources that still hold once, in aWITH holding AS MATERIALIZEDCTE, and deletes against it with an anti-join. The conditions are the same, including the mood check throughno_mood_spoken(), so the same rows are deleted. On that base the new shape, run as a read-only count, finishes in 2 min 23 s and selects 44,892 sources. The statement now lives in a smallsource_cleanup_sql()function so a test can plan it.The test is a plan test next to the existing one in
materialize_plan_tests.rs. It runsEXPLAINon the statement and checks that the plan buildsCTE holdingand the delete scans it, which fails on the old statement. The behaviour tests intests/store/are unchanged and green.This follows the proposal in the issue, and we are glad to reshape it however you prefer. Thank you for looking!