[spark] Add point-delete fast path for primary key DELETE to skip the target table scan#8837
Open
ZZZxDong wants to merge 1 commit into
Open
[spark] Add point-delete fast path for primary key DELETE to skip the target table scan#8837ZZZxDong wants to merge 1 commit into
ZZZxDong wants to merge 1 commit into
Conversation
… target table scan
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.
Purpose
Closes #8836.
Currently
DELETE FROMon a primary-key table always scans the target table to locate matching rows, even when the condition is nothing but primary keys. In that case the matched keys are already fully described by the condition, so we can build the-Drecords directly and skip the scan.This PR adds a fast path to
DeleteFromPaimonTableCommandfor the pk-upsert delete:pk = literal/pk IN (literals)covering all pk columns-Drows from the condition on the driver (capped bydelete.point-delete.max-rows, default 1M, falls back to scan beyond that)pk IN (subquery)covering all pk columnsKeys absent from the table are harmless: their
-Drecords simply merge away in compaction, which matches the semantics of the existing path.Tests
DeletePointFastPathTest: literal IN / equality / composite pk, subquery with single and composite pk (including positionally-renamed columns), fallback cases (non-pk column in condition, pk not fully pinned), delete-then-reinsert. Also ran the existingDeleteFromTableTestsuite (29 tests) — all pass, no behavior change.API and Format
New connector option
delete.point-delete.max-rows(default 1000000). No format change.Documentation
N/A