-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
opt: build partial index predicates as FiltersExprs #51164
Merged
Merged
Conversation
This file contains 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
mgartner
force-pushed
the
predicate-filters-expr
branch
from
July 8, 2020 17:59
9cc10c7
to
2f593db
Compare
RaduBerinde
approved these changes
Jul 8, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained
mgartner
force-pushed
the
predicate-filters-expr
branch
from
July 8, 2020 22:39
2f593db
to
b56a675
Compare
bors r=RaduBerinde |
bors r=RaduBerinde |
Build failed |
This commit updates optbuilder to build a partial index predicate as `FiltersExpr` instead of an arbitrary ScalarExpr. The primary reason for doing so is to make it easier to calculate statistics for partial index scans. By representing the predicate as a `FiltersExpr`, the statistics builder can generate stats for partial index scans using existing functions that help generate statistics for Selects. `SimplifyFilters` and `ConsolidateFilters` are manually called on the predicate so that it is similar in form to a normalized Select filter. Flattening the expression and generating constraints for each top-level conjunction will make it simpler and cheaper to calculate stats accurately for unapplied conjunctions. This commit also updates `Implicator` to handle predicates that are `FiltersExpr`s and have `RangeExpr`s in them. This change benefits the performance of `Implicator` significantly in some of the slowest benchmark cases because flattening predicate conjunctions means that the exact-match fast path can prove implication in more cases. This change only worsens performance significantly in some of the fastest cases that take <400ns/op. name old time/op new time/op delta Implicator/single-exact-match-16 61.7ns ± 0% 89.1ns ± 0% +44.47% (p=0.008 n=5+5) Implicator/single-inexact-match-16 878ns ± 0% 912ns ± 1% +3.94% (p=0.008 n=5+5) Implicator/range-inexact-match-16 2.32µs ± 2% 2.40µs ± 1% +3.78% (p=0.008 n=5+5) Implicator/single-exact-match-extra-filters-16 321ns ± 1% 371ns ± 1% +15.70% (p=0.008 n=5+5) Implicator/single-inexact-match-extra-filters-16 4.00µs ± 0% 4.11µs ± 1% +2.78% (p=0.008 n=5+5) Implicator/multi-column-and-exact-match-16 455ns ± 0% 100ns ± 1% -78.02% (p=0.016 n=4+5) Implicator/multi-column-and-inexact-match-16 1.94µs ± 1% 1.97µs ± 0% +1.32% (p=0.040 n=5+5) Implicator/multi-column-or-exact-match-16 62.1ns ± 0% 91.4ns ± 0% +47.23% (p=0.008 n=5+5) Implicator/multi-column-or-exact-match-reverse-16 1.72µs ± 0% 1.79µs ± 0% +4.08% (p=0.008 n=5+5) Implicator/multi-column-or-inexact-match-16 2.18µs ± 0% 2.25µs ± 1% +3.56% (p=0.008 n=5+5) Implicator/and-filters-do-not-imply-pred-16 3.65µs ± 2% 3.76µs ± 5% ~ (p=0.056 n=5+5) Implicator/or-filters-do-not-imply-pred-16 774ns ± 1% 850ns ± 1% +9.71% (p=0.008 n=5+5) Implicator/many-columns-exact-match10-16 4.93µs ± 1% 0.30µs ± 1% -93.87% (p=0.008 n=5+5) Implicator/many-columns-inexact-match10-16 11.3µs ± 1% 11.1µs ± 0% -1.86% (p=0.008 n=5+5) Implicator/many-columns-exact-match100-16 352µs ± 1% 18µs ± 1% -94.92% (p=0.008 n=5+5) Implicator/many-columns-inexact-match100-16 382µs ± 1% 372µs ± 1% -2.47% (p=0.008 n=5+5) Release note: None
mgartner
force-pushed
the
predicate-filters-expr
branch
from
July 9, 2020 17:00
b56a675
to
be87984
Compare
bors r=RaduBerinde |
Build succeeded |
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.
This commit updates optbuilder to build a partial index predicate as
FiltersExpr
instead of an arbitrary ScalarExpr. The primary reason fordoing so is to make it easier to calculate statistics for partial index
scans. By representing the predicate as a
FiltersExpr
, the statisticsbuilder can generate stats for partial index scans using existing
functions that help generate statistics for Selects.
SimplifyFilters
andConsolidateFilters
are manually called on thepredicate so that it is similar in form to a normalized Select filter.
Flattening the expression and generating constraints for each top-level
conjunction will make it simpler and cheaper to calculate stats
accurately for unapplied conjunctions.
This commit also updates
Implicator
to handle predicates that areFiltersExpr
s and haveRangeExpr
s in them. This change benefits theperformance of
Implicator
significantly in some of the slowestbenchmark cases because flattening predicate conjunctions means that the
exact-match fast path can prove implication in more cases. This change
only worsens performance significantly in some of the fastest cases that
take <400ns/op.
Release note: None