Skip to content

Fix overlap detection with running max#10315

Open
Poroma-Banerjee wants to merge 1 commit into
timescale:mainfrom
Poroma-Banerjee:tscompress
Open

Fix overlap detection with running max#10315
Poroma-Banerjee wants to merge 1 commit into
timescale:mainfrom
Poroma-Banerjee:tscompress

Conversation

@Poroma-Banerjee

Copy link
Copy Markdown
Member

Overlap detection compared only against the immediately previous batch's last value. A small intermediate batch (e.g. a 1-row boundary batch) could reset the comparison point and hide overlaps with later batches, requiring multiple compaction passes to converge.

Track the running maximum of last values instead, so all overlaps within a segment are detected in a single pass. Uses full-tuple comparison to avoid mixing column values from different batches in multi-column orderby.

@Poroma-Banerjee Poroma-Banerjee added the Columnstore Related to the column store / compression label Jul 24, 2026
@github-actions
github-actions Bot requested a review from dbeck July 24, 2026 04:24
@github-actions

Copy link
Copy Markdown

@dbeck, @svenklemm: please review this pull request.

Powered by pull-review

@github-actions
github-actions Bot requested a review from svenklemm July 24, 2026 04:24
@Poroma-Banerjee Poroma-Banerjee added this to the v2.29.0 milestone Jul 24, 2026
Overlap detection compared only against the immediately
previous batch's last value. A small intermediate batch
(e.g. a 1-row boundary batch) could reset the comparison
point and hide overlaps with later batches, requiring
multiple compaction passes to converge.

Track the running maximum of last values instead, so all
overlaps within a segment are detected in a single pass.
Uses full-tuple comparison to avoid mixing column values
from different batches in multi-column orderby.
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
tsl/src/compression/recompress.c 93.54% 0 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@philkra philkra added the force-auto-backport Automatically backport this PR or fix of this issue, even if it's not marked as "bug" label Jul 24, 2026
DROP TABLE metrics_max_batches;

-- Test Small intermediate batches must not hide overlaps with later batches.
CREATE TABLE metrics_running_max (time TIMESTAMPTZ NOT NULL, value float)

@natalya-aksman natalya-aksman Jul 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's also test DESC order i.e. for time DESC for example.
Multikey orderby with different key direction would also be interesting to test.

Also, would be interesting to test on compressed hypertable with segmentby.

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

Labels

Columnstore Related to the column store / compression force-auto-backport Automatically backport this PR or fix of this issue, even if it's not marked as "bug"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants