Skip to content

Disable IN clause threshold with query parameter so we can prune at broker for large IN clauses - #19280

Merged
Jackie-Jiang merged 3 commits into
apache:masterfrom
a34729t:issue-19279-query-option-to-force-pruning-in-clause
Aug 19, 2026
Merged

Disable IN clause threshold with query parameter so we can prune at broker for large IN clauses#19280
Jackie-Jiang merged 3 commits into
apache:masterfrom
a34729t:issue-19279-query-option-to-force-pruning-in-clause

Conversation

@a34729t

@a34729t a34729t commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Per #19279, it would be convenient to have a query parameter that disables the IN clause pruning threshold.


Summary

  • Add the inPredicatePruningThreshold query option to override the server inpredicate.threshold (default 10) on a per-query basis. A negative value disables the threshold entirely, so IN-predicate segment pruning is always attempted regardless of IN-clause size.

Usage

Added a per-query integer query option inPredicatePruningThreshold:

  -- Raise the threshold for this query
  SET inPredicatePruningThreshold=501;
  SELECT ... WHERE id IN (a, b, ..., 500 values)

  -- Or disable the threshold entirely (negative value = always
prune)
  SET inPredicatePruningThreshold=-1;
  SELECT ... WHERE id IN (a, b, ..., 500 values)

A negative value means the pruners always attempt to prune segments for IN predicates, regardless of the clause size. When unset, the server-configured inpredicate.threshold (default 10) applies, preserving existing behavior.

Pruning is per-segment and all-or-nothing. The pruner either skips a whole segment (none of the IN values exist in it) or keeps it. On a single-segment table there is nothing to skip, so no pruning is observed (my local test cluster setup); in a larger cluster, segments that contain none of the IN values are pruned.

Testing

Unit tests cover:

  • QueryOptionsUtils getter
  • End-to-end pruning of a >10-value IN list in both ColumnValueSegmentPrunerTest and BloomFilterSegmentPrunerTest, with negative and positive overrides
  • Negative server config (inpredicate.threshold = -1) prunes without any query option

Also tested in my local Pinot cluster setup and ran a few queries to validate query plans and behavior (both SSE and MSE).

@Jackie-Jiang Jackie-Jiang added query Related to query processing feature New functionality labels Aug 17, 2026

@Jackie-Jiang Jackie-Jiang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mostly good

/// When true, the column-value and bloom-filter segment pruners always attempt to prune segments for
/// IN predicates, regardless of the number of values in the IN clause (i.e. the server-configured
/// `inpredicate.threshold` is ignored for this query). Defaults to false.
public static final String FORCE_IN_PREDICATE_PRUNING = "forceInPredicatePruning";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To be more flexible, we can consider making it IN_PREDICATE_PRUNING_THRESHOLD, and use negative number to represent always pruning. This way it becomes a query level override. We can modify the server level one to follow the same convention

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

/// doesn't mean this child filter can prune the segment.
/// 4. The specific pruners decide their own applicable predicate types.
private boolean isApplicableToFilter(FilterContext filter) {
private boolean isApplicableToFilter(FilterContext filter, boolean forceInPredicatePruning) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pass in query.getQueryOptions() as second argument to be more flexible, and also avoid option parsing for non-IN clauses

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@Jackie-Jiang Jackie-Jiang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well done!

@codecov-commenter

codecov-commenter commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.08%. Comparing base (c27e3a7) to head (54a4078).
⚠️ Report is 36 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #19280      +/-   ##
============================================
+ Coverage     66.98%   67.08%   +0.10%     
- Complexity     1423     1424       +1     
============================================
  Files          3453     3459       +6     
  Lines        218960   219795     +835     
  Branches      34805    35009     +204     
============================================
+ Hits         146672   147460     +788     
+ Misses        60566    60550      -16     
- Partials      11722    11785      +63     
Flag Coverage Δ
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 ?
java-25 67.08% <100.00%> (+0.10%) ⬆️
lane-a 100.00% <ø> (ø)
lane-b 0.00% <ø> (ø)
temurin 67.08% <100.00%> (+0.10%) ⬆️
unittests 67.08% <100.00%> (+0.10%) ⬆️
unittests1 57.72% <100.00%> (+<0.01%) ⬆️
unittests2 39.19% <0.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Jackie-Jiang
Jackie-Jiang merged commit e4888b0 into apache:master Aug 19, 2026
11 of 12 checks passed
xiangfu0 added a commit to pinot-contrib/pinot-docs that referenced this pull request Aug 19, 2026
## Summary

- add `inPredicatePruningThreshold` to the query-options reference
- document positive overrides and the negative always-attempt mode
- clarify the server fallback and whole-segment pruning semantics

## Upstream context

Follows apache/pinot#19280.

## Validation

- `git diff --check`

Co-authored-by: Xiang Fu <xiangfu@Xiang-mac-mtv-2.local>
@xiangfu0

Copy link
Copy Markdown
Contributor

The follow-up documentation is available in pinot-contrib/pinot-docs#997: pinot-contrib/pinot-docs#997

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

Labels

feature New functionality query Related to query processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants