Add Temporal Merge Policy for time-series data #15620
Open
+1,640
−0
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.
Description
This PR introduces TemporalMergePolicy, a new merge policy designed for time-series workloads where documents contain a timestamp field. The policy groups segments into time windows and merges segments within the same window, but never merges segments across different time windows. This preserves temporal locality and improves query performance for time-range queries. relates to #15412.
How it works
Time Bucketing
Merge Triggers
Merges are triggered when a time window meets two conditions:
Key Constraints
Handling Late-Arriving and Out-of-Order Data
Time-series data rarely arrives perfectly in order. TemporalMergePolicy handles various timing scenarios:
Late-Arriving Data
When data with older timestamps arrives after newer data has been indexed:
Example:
Result: Segments A and C can merge together (same bucket), but never with B
Future Data
Data with timestamps in the future (beyond current time):
Out-of-Order Writes Within a Segment
If a single segment contains documents spanning multiple time windows: