perf: narrow scan projection in merge_insert partial schema to avoid heavy column I/O#7443
Open
hfutatzhanghb wants to merge 1 commit into
Open
Conversation
…ing cols in write exec
d6a4984 to
2cae88e
Compare
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.
Summary
When performing
merge_insertwith a partial schema (e.g. only key + embedding columns for updates), the table scan in the join phase exposes ALL dataset columns. While DataFusion's optimizer can push projections down, thetarget."column_name"synthetic column references in the post-join loop effectively block this optimization — the planner sees references to every dataset column and must scan them all.For large tables (1B rows, 20TB) where only 50K embedding values need updating, this means the join scans 20TB of data unnecessarily.
Fix
When a partial schema is detected (
source_field_names.len() < self.dataset.schema().fields.len()), narrow the target scan to only_rowid,_rowaddr, and on-columns before the join viaDataFrame::select_columns. DataFusion pushes this projection down to the table scan, avoiding I/O on heavy data columns during matching.The
target."column_name"synthetic column references in the post-join loop are unaffected — DataFusion's projection-pushdown operates at the physical-plan level and does not invalidate logical column references.Performance Impact
_rowid+_rowaddr+ on-columns (~16GB)Testing
cargo check -p lance --libpassescargo fmt --allpasses