Core: Add rewrite-stale-sort-order option to RewriteDataFiles planner to support incremental sort #16330
Open
talatuyarer wants to merge 2 commits into
Open
Core: Add rewrite-stale-sort-order option to RewriteDataFiles planner to support incremental sort #16330talatuyarer wants to merge 2 commits into
talatuyarer wants to merge 2 commits into
Conversation
Member
|
I kind of want to do something smarter than this long term, but that is probably a good first step. For example just because a file was "written" with a sort order doesn't mean it shouldn't be resorted In the original doc for example I proposed looking at overlaps and only selecting files for rewriting where the overlap depth was at a certain level. Like for example if I have files [1 - 100] - SortId 1 Just rewriting the last file doesn't make sense, and ignoring the first three is probably a mistake |
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.
RewriteDataFiles with the SORT strategy currently re-sorts every file the planner selects, regardless of whether that file is already sorted by the table's current sort order. The
BinPackRewriteFilePlannerselects files purely based on size and delete-file metadata (min/max-file-size-bytes, delete-file-threshold, delete-ratio-threshold) and has no awareness ofsort_order_id, even though every data file already records the sort order it was written with.I believe repeated sort maintenance is wasteful. Operators who run sort compaction on a schedule re-shuffle and rewrite data that is already correctly sorted on every run. Additionally, there is no targeted path for sort-order evolution. When a table's sort order changes, existing files keep their old
sort_order_id. Today, the only way to realign them is withrewrite-all, which also rewrites files that are already sorted correctly.I added a boolean planner option,
rewrite-stale-sort-order(default: false), toBinPackRewriteFilePlanner. When enabled, the planner additionally selects data files whosesort_order_iddoes not match the table's current default sort order ID. This allows a sort-based rewrite to reorganize only the files not already sorted by the current order.I believe this is a natural extension of the planner's existing metadata-driven selection, as
sort_order_idis another piece of already-recorded file metadata the planner can use to decide what is worth rewriting. It is intended for use with the SORT strategy, so rewritten files are stamped with the table's current sort order ID.