Skip to content

Avoid a case where the planner was erroneously dropping predicates#3965

Open
alecgrieser wants to merge 2 commits intoFoundationDB:mainfrom
alecgrieser:03950-keep-range-constraints
Open

Avoid a case where the planner was erroneously dropping predicates#3965
alecgrieser wants to merge 2 commits intoFoundationDB:mainfrom
alecgrieser:03950-keep-range-constraints

Conversation

@alecgrieser
Copy link
Collaborator

There was a case in RangeConstraints.asComparisonRange where the process of merging different comparison ranges could result in predicates being dropped. The fundamental error was that there is a function, merge, which merges a comparison into a comparison range. However, if the comparison can't be successfully merged, then it will be added to a residual comparison list. But the asComparisonRange function was ignoring those predicates entirely.

This modifies the method so that it collects the ranges rather than dropping them. It then also modifies the compensation function so that if there are residual predicates, we are sure to generate a predicate for it.

This fixes #3950.

@alecgrieser alecgrieser added the bug fix Change that fixes a bug label Feb 20, 2026
@alecgrieser alecgrieser force-pushed the 03950-keep-range-constraints branch from 79c4b37 to 3911001 Compare February 20, 2026 18:21
@alecgrieser alecgrieser marked this pull request as ready for review February 23, 2026 12:23
@alecgrieser alecgrieser force-pushed the 03950-keep-range-constraints branch 3 times, most recently from 97d21e5 to ddd955b Compare February 23, 2026 14:05
@alecgrieser alecgrieser requested a review from hatyo February 23, 2026 14:12
… in the compaensation as needed

Validate behavior in new query test, as well as in more purpose built unit tests.
@alecgrieser alecgrieser force-pushed the 03950-keep-range-constraints branch from cbb9a3e to 5ade72f Compare March 2, 2026 12:05
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

📊 Metrics Diff Analysis Report

Summary

  • New queries: 6
  • Dropped queries: 0
  • Plan changed + metrics changed: 4
  • Plan unchanged + metrics changed: 0
ℹ️ About this analysis

This automated analysis compares query planner metrics between the base branch and this PR. It categorizes changes into:

  • New queries: Queries added in this PR
  • Dropped queries: Queries removed in this PR. These should be reviewed to ensure we are not losing coverage.
  • Plan changed + metrics changed: The query plan has changed along with planner metrics.
  • Metrics only changed: Same plan but different metrics

The last category in particular may indicate planner regressions that should be investigated.

New Queries

Count of new queries by file:

  • yaml-tests/src/test/resources/join-tests.metrics.yaml: 5
  • yaml-tests/src/test/resources/sql-functions.metrics.yaml: 1

Plan and Metrics Changed

These queries experienced both plan and metrics changes. This generally indicates that there was some planner change
that means the planning for this query may be substantially different. Some amount of query plan metrics change is expected,
but the reviewer should still validate that these changes are not excessive.

Total: 4 queries

Statistical Summary (Plan and Metrics Changed)

task_count:

  • Average change: +88.0
  • Average regression: +88.0
  • Median change: +98
  • Median regression: +98
  • Standard deviation: 20.9
  • Standard deviation of regressions: 20.9
  • Range: +52 to +104
  • Range of regressions: +52 to +104
  • Queries changed: 4
  • Queries regressed: 4

transform_count:

  • Average change: +15.5
  • Average regression: +15.5
  • Median change: +18
  • Median regression: +18
  • Standard deviation: 4.3
  • Standard deviation of regressions: 4.3
  • Range: +8 to +18
  • Range of regressions: +8 to +18
  • Queries changed: 4
  • Queries regressed: 4

transform_yield_count:

  • Average change: +3.5
  • Average regression: +3.5
  • Median change: +4
  • Median regression: +4
  • Standard deviation: 0.9
  • Standard deviation of regressions: 0.9
  • Range: +2 to +4
  • Range of regressions: +2 to +4
  • Queries changed: 4
  • Queries regressed: 4

insert_new_count:

  • Average change: +12.8
  • Average regression: +12.8
  • Median change: +14
  • Median regression: +14
  • Standard deviation: 3.4
  • Standard deviation of regressions: 3.4
  • Range: +7 to +16
  • Range of regressions: +7 to +16
  • Queries changed: 4
  • Queries regressed: 4

insert_reused_count:

  • Average change: +2.0
  • Average regression: +2.0
  • Median change: +2
  • Median regression: +2
  • Standard deviation: 0.0
  • Standard deviation of regressions: 0.0
  • Range: +2 to +2
  • Range of regressions: +2 to +2
  • Queries changed: 1
  • Queries regressed: 1

There were no queries with significant regressions detected.

Minor Changes (Plan and Metrics Changed)

In addition, there were 4 queries with minor changes.

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

Labels

bug fix Change that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RangeConstraints.asComparisonRange can result in predicates being lost

1 participant