Skip to content

[Feature](scan) add variable adjust_tablet_reader_batch_size_by_limit#61003

Open
BiteTheDDDDt wants to merge 1 commit intoapache:masterfrom
BiteTheDDDDt:dev_0303_3
Open

[Feature](scan) add variable adjust_tablet_reader_batch_size_by_limit#61003
BiteTheDDDDt wants to merge 1 commit intoapache:masterfrom
BiteTheDDDDt:dev_0303_3

Conversation

@BiteTheDDDDt
Copy link
Contributor

What problem does this PR solve?

after #22240, we do not push limit to tablet reader.
but sometime the row data is big, so we need use limit to scan less data.

adjust_tablet_reader_batch_size_by_limit=false;

  • ScanRows: sum 16.32K (16320), avg 16.32K (16320), max 16.32K (16320), min 16.32K (16320)
    adjust_tablet_reader_batch_size_by_limit=true;
  • ScanRows: sum 200, avg 200, max 200, min 200

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

Copilot AI review requested due to automatic review settings March 3, 2026 12:43
@Thearas
Copy link
Contributor

Thearas commented Mar 3, 2026

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@BiteTheDDDDt
Copy link
Contributor Author

run buildall

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new session/query option to optionally size the OLAP tablet reader’s batch size based on the query LIMIT, aiming to reduce scan work for queries with small limits (especially when rows are wide).

Changes:

  • Added adjust_tablet_reader_batch_size_by_limit to TQueryOptions (Thrift) and to FE session variables (forwarded to BE).
  • Added a RuntimeState accessor for the new option in BE.
  • Updated OlapScanner::prepare() to optionally set tablet reader batch size to min(batch_size, limit) when enabled.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
gensrc/thrift/PaloInternalService.thrift Adds a new optional TQueryOptions boolean field to carry the flag from FE to BE.
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java Defines the session variable and forwards it into TQueryOptions via toThrift().
be/src/runtime/runtime_state.h Adds a helper to read the new option from TQueryOptions safely.
be/src/vec/exec/scan/olap_scanner.cpp Applies the option by adjusting BlockReader batch size based on scanner limit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hello-stephen
Copy link
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 79.34% (1797/2265)
Line Coverage 64.80% (32202/49698)
Region Coverage 65.62% (16109/24550)
Branch Coverage 56.13% (8585/15294)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 55.56% (5/9) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.56% (26176/36577)
Line Coverage 54.35% (274452/505015)
Region Coverage 51.71% (228489/441893)
Branch Coverage 53.02% (98103/185014)

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (2/2) 🎉
Increment coverage report
Complete coverage report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants