timescaledb
timescaledb copied to clipboard
Speed up chunk search by restriction clauses
We don't have to look up the dimension slices for dimensions for which we don't have restrictions.
This also fixes a planning time regression introduced in 2.7. It was introduced in this commit https://github.com/timescale/timescaledb/commit/37190e8a8#diff-e488f45c83647e5d9415d438f2e79eb2780639b7888c7533890b6c577e02d03dL852-L857 We stopped using the fast path for case where there are no restrictions, and the normal path turned out to be slower. This commit speeds it up to the previous level.
The lookup logic this PR introduces is basically the same as the one introduced for chunk_point_find_chunk_id
by https://github.com/timescale/timescaledb/pull/4390 . The difference is that here the conditions may be underspecified, so multiple chunks match.
For reviewing purposes, it would be good to understand what change introduced the regression.
Codecov Report
Merging #4492 (87dfc27) into main (a26a597) will increase coverage by
0.03%
. The diff coverage is96.59%
.
@@ Coverage Diff @@
## main #4492 +/- ##
==========================================
+ Coverage 90.82% 90.85% +0.03%
==========================================
Files 224 224
Lines 42344 41654 -690
==========================================
- Hits 38457 37843 -614
+ Misses 3887 3811 -76
Impacted Files | Coverage Δ | |
---|---|---|
src/chunk.h | 100.00% <ø> (ø) |
|
src/compat/compat.h | 94.59% <87.50%> (-0.53%) |
:arrow_down: |
src/hypertable_restrict_info.c | 94.50% <91.89%> (-1.35%) |
:arrow_down: |
src/chunk_scan.c | 98.47% <98.73%> (+2.61%) |
:arrow_up: |
src/chunk.c | 88.37% <100.00%> (-6.73%) |
:arrow_down: |
src/planner/expand_hypertable.c | 93.94% <100.00%> (-0.03%) |
:arrow_down: |
tsl/src/nodes/compress_dml/compress_dml.c | 90.47% <0.00%> (-9.53%) |
:arrow_down: |
src/chunk_constraint.c | 90.07% <0.00%> (-3.88%) |
:arrow_down: |
tsl/src/partialize_finalize.c | 92.44% <0.00%> (-3.73%) |
:arrow_down: |
... and 25 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update a26a597...87dfc27. Read the comment docs.
For reviewing purposes, it would be good to understand what change introduced the regression.
I updated the description.
https://grafana.ops.savannah-dev.timescale.com/d/NdmLnOk4z/compare-benchmark-runs?orgId=1&var-branch=main&var-branch=release&var-branch=pr&var-postgres=14&var-run1=379&var-run2=397&var-threshold=0.02
Looks like this does improve some queries, although not all of them.