[Improve][Connector-Clickhouse] improve ck batch parallel read by using last batch row sorting value approach, instead of limit offset.#9801
Merged
Conversation
…ng last batch row sorting value approach, instead of limit offset.
Hisoka-X
reviewed
Sep 1, 2025
| } else { | ||
| return clickhouseSourceSplit.getParts().stream() | ||
| .map(ClickhouseValueReader.this::buildPartQuery) | ||
| .map(this::buildStreamPartQuery) |
Contributor
Author
There was a problem hiding this comment.
Actually, I just want to separate the methods for building query sql in different modes. The buildBatchSqlQuery and buildBatchPartQuery methods are only used for sql query construction in batch mode. This way, there is no need to make additional logical judgments within the method regarding the generation of sql in the Stream scenario.
Hisoka-X
reviewed
Sep 2, 2025
Comment on lines
+347
to
+350
| Method buildKeysetWhereConditionMethod = | ||
| ClickhouseValueReader.class.getDeclaredMethod( | ||
| "buildKeysetWhereCondition", String.class, List.class); | ||
| buildKeysetWhereConditionMethod.setAccessible(true); |
Member
There was a problem hiding this comment.
Could you reuse
corgy-w
approved these changes
Sep 8, 2025
3 tasks
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 of this pull request
Improve ck batch parallel read by using last batch row sorting value approach, instead of limit offset.
When reading large amounts of data, using the limit offset method will first construct the complete result set and then skip the number of rows specified by the offset. The larger the value of OFFSET is, the higher the cost of the query will be. Therefore, for the optimization of batch reading, the maximum value of the sorting key of the last batch is recorded. This approach utilizes the WHERE condition to "skip" the previous data.
before:

after:

Does this PR introduce any user-facing change?
How was this patch tested?
Check list
New License Guide