Skip to content

Switch the samples inner table of the TimeSeries engine to a bucketed schema - #117344

Merged
vitlibar merged 3 commits into
ClickHouse:masterfrom
vitlibar:time-series-bucketed-samples-table
Oct 28, 2026
Merged

vitlibar merged 3 commits into
ClickHouse:masterfrom
vitlibar:time-series-bucketed-samples-table

Conversation

@vitlibar

@vitlibar vitlibar commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Experimental Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Switch the samples inner table of the TimeSeries engine to a bucketed schema:

CREATE TABLE default.`.inner_id.samples.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`
(
    `id` Tuple(UInt64, LowCardinality(UUID)),
    `samples` SimpleAggregateFunction(timeSeriesGroupArray, Array(Tuple(timestamp DateTime64(3), value Float64))),
    `bucket` DateTime64(3) CODEC(Delta(8), T64, ZSTD(3)),
    `min_time` SimpleAggregateFunction(min, DateTime64(3)) CODEC(Delta(8), T64, ZSTD(3)),
    `max_time` SimpleAggregateFunction(max, DateTime64(3)) CODEC(Delta(8), T64, ZSTD(3)),
    CODEC `samples.timestamp` (Delta(8), T64, ZSTD(3)),
    CODEC `samples.value` (ALP, ZSTD(3))
)
ENGINE = AggregatingMergeTree
PARTITION BY toYYYYMM(toDateTime(bucket, 'UTC'))
ORDER BY (id, bucket)
SETTINGS index_granularity = 256, index_granularity_bytes = 524288

The recent samples table has the same columns and codecs. It differs only in the engine clause: five-hour partitions, the TTL toDateTime(bucket) + toIntervalSecond(346500), and index_granularity_bytes = 131072.


Workflow [PR]
Sync PR [sync-upstream/pr/117344]

Version info

  • Merged into: 26.11.1.841-master (included in 26.11 and later)

@vitlibar vitlibar added the comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... label Aug 31, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [819b40d]

Summary: ❌

job_name test_name status info comment
Build profile diff ERROR

AI Review

Summary

The PR introduces version 11 of TimeSeries, storing sorted sample arrays in time buckets and adapting SQL, PromQL, and remote reads. ❌ Block: custom merge keys can make stored samples unqueryable, and a previously valid legacy definition can fail attachment. Six previously discussed findings remain in the current code. All were dismissed by the author and are retained here without reopening or duplicating their inline threads. No genuinely new inline findings were identified.

Findings

❌ Blockers

  • src/Storages/TimeSeries/normalizeTimeSeriesDefinitionImpl.cpp:1943 — Custom sorting keys can destroy bucket identity. SAMPLES INNER ENGINE = AggregatingMergeTree ORDER BY id remains accepted. Samples at timestamps 100 and 3700 for the same series share a monthly partition and merge into one array with only one ordinary bucket value. A selector for the other bucket then rejects that row and loses the matching sample. Validate that custom merge keys preserve both id and bucket, for both samples targets. [dismissed by author -- Switch the samples inner table of the TimeSeries engine to a bucketed schema #117344 (comment)] The explicit-key path still bypasses the generated key, so the loss remains possible.

  • src/Storages/TimeSeries/normalizeTimeSeriesDefinitionImpl.cpp:218 — Legacy attachment no longer preserves supported schemas. An inner column such as samples String DEFAULT 'extra' was allowed in version 10, but is now interpreted as the bucketed aggregate carrier regardless of version. Type resolution runs during attachment and throws BAD_TYPE_OF_FIELD, preventing the existing table from loading after upgrade. Restrict this interpretation to bucketed versions. [dismissed by author -- Switch the samples inner table of the TimeSeries engine to a bucketed schema #117344 (comment)] Pinning version = 10 still does not bypass the new interpretation.

⚠️ Majors

  • src/Storages/TimeSeries/normalizeTimeSeriesDefinitionImpl.cpp:1933 — Copied extra columns can prevent table creation. Legacy extra plain columns survive CREATE TABLE ... AS, but the generated samples engine is now AggregatingMergeTree without allow_dimensions_outside_sorting_key. An extra String or UInt8 column outside the keys fails engine validation; the normalization unit test still expects such a copy to work. Preserve this supported case explicitly. [dismissed by author -- Switch the samples inner table of the TimeSeries engine to a bucketed schema #117344 (comment)] Only the tags branch enables the setting; the samples targets remain affected.

  • src/Storages/TimeSeries/normalizeTimeSeriesDefinitionImpl.cpp:854 — Schema conversion leaves dependencies on removed columns. Copying a version-10 table with INDEX time_idx timestamp TYPE minmax GRANULARITY 1 removes timestamp but retains its index, so CREATE TABLE copy AS source fails. Copied SAMPLE BY timestamp clauses have the same gap. Remove or translate dependent declarations when converting layouts. [dismissed by author -- Switch the samples inner table of the TimeSeries engine to a bucketed schema #117344 (comment)] Column cleanup still handles only columns and codecs, and engine cleanup omits sample_by.

  • src/Storages/TimeSeries/normalizeTimeSeriesDefinitionImpl.cpp:1459 — Explicit codecs collide with generated defaults. SAMPLES INNER COLUMNS (CODEC samples.timestamp (DoubleDelta, ZSTD(1))) generates the missing samples column and appends a second codec for the same subcolumn, causing creation to fail. Supply each default only when no explicit declaration exists, including the recent samples target. [dismissed by author -- Switch the samples inner table of the TimeSeries engine to a bucketed schema #117344 (comment)] Default codec insertion is still unconditional.

  • src/Functions/TimeSeries/timeSeriesSliceSortedArray.cpp:93 — Out-of-domain bounds can lose matching samples. With UInt32 timestamps, slicing [(0, 1.)] over [-10, 5] wraps the lower bound to 4294967286 and returns an empty array. Clamp overlapping bounds and return empty for disjoint domains, or reject unrepresentable bounds explicitly. [dismissed by author -- Switch the samples inner table of the TimeSeries engine to a bucketed schema #117344 (comment)] The direct function still uses unchecked casts; the selector's corrected conversion does not protect direct calls.

Tests
  • ⚠️ Add focused SQL regressions for custom two-bucket merges, legacy attachment with an extra samples column, copied extra columns and index dependencies, generated-column codec overrides, and direct unsigned-bound slicing. Existing coverage does not establish these contracts. The findings above are based on source traces; no local ClickHouse binary or build directory was available for runtime reproduction.
  • ⚠️ The modified performance tests do not fully compare against the reference binary: promql_selector_pk_range.xml:20 tolerates reference setup failure, and the direct selector queries in promql_selector_id_range_row_cost.xml:34 use a signature the reference does not support. Provide equivalent-query measurements on both binaries to establish index-analysis and direct-selector performance.
Final Verdict

❌ Block. Preserve bucket identity under custom merge keys and keep legacy definitions attachable. Address the remaining creation and slicing failures with focused regressions. Previously dismissed findings remain summary-only; no inline comments or thread replies were posted in this run.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Aug 31, 2026
@vitlibar vitlibar added the do not test disable testing on pull request label Aug 31, 2026
@vitlibar vitlibar changed the title Switch the samples inner table of the TimeSeries engine to a bucketed schema [WIP] Switch the samples inner table of the TimeSeries engine to a bucketed schema Sep 8, 2026
@vitlibar
vitlibar force-pushed the time-series-bucketed-samples-table branch 4 times, most recently from 0226aa6 to e23c7c6 Compare September 10, 2026 09:23
@vitlibar vitlibar removed the do not test disable testing on pull request label Sep 10, 2026
@vitlibar vitlibar changed the title [WIP] Switch the samples inner table of the TimeSeries engine to a bucketed schema Switch the samples inner table of the TimeSeries engine to a bucketed schema Sep 10, 2026
@vitlibar
vitlibar marked this pull request as ready for review September 10, 2026 09:24
Comment thread src/Common/DateLUTImpl.h
return lut[toLUTIndex(v)];
}

/// Round `value` down to a multiple of `divisor` (towards negative infinity).

@vitlibar vitlibar Sep 10, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Function DateLUTImpl::roundDownToMultiple was just made public, because I need it for bucket calculations

@vitlibar
vitlibar force-pushed the time-series-bucketed-samples-table branch from e23c7c6 to f0e2ee1 Compare September 10, 2026 11:36
@vitlibar
vitlibar force-pushed the time-series-bucketed-samples-table branch 2 times, most recently from b7d0568 to 15c4f3b Compare September 10, 2026 12:58
@vitlibar
vitlibar force-pushed the time-series-bucketed-samples-table branch from 15c4f3b to f858f39 Compare September 10, 2026 14:36
@clickhouse-gh

clickhouse-gh Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing commit 819b40d672260427f7e9bf69ba1bb1d42a2940e6 with master failed: LogClusterNotReady: the endpoint never became ready.

See the job log for details.

@vitlibar
vitlibar force-pushed the time-series-bucketed-samples-table branch from f858f39 to cc55590 Compare September 10, 2026 19:14
@snelheidai

Copy link
Copy Markdown

Measurements on this PR's samples schema: short windows over many series depend on the recent table, and a time-bucket prefix in the main sort key would serve them at close to recent-table speed from one table.

I rewrote 7 days of synthetic node-exporter data (19,800 series, 15 s interval, 798M samples) into the PR's layout: one row per series-hour with samples Array(Tuple(timestamp, value)) CODEC(ZSTD(3)). Every layout ran the same hand-written read of the selected series' samples in the window, with identical results. The 200- and 12,800-series queries each select a whole metric, whose series are adjacent because the default id starts with the metric hash. Values are median server-side durations of 10 interleaved runs; the 200-series column also shows the data decompressed.

Layout (granules 512 rows / 512 KiB unless noted) 200 series, 1 h 12,800 series, 6 h 1 series, 7 days
PR main: PARTITION BY toYYYYMM(bucket) ORDER BY (id, bucket) 195 ms (100 MiB) 6075 ms 6.3 ms
PR main with index_granularity_bytes = 65536 73 ms (37 MiB) 2355 ms 6.7 ms
PR recent: 5 h partitions, 256 rows / 256 KiB 11.1 ms (3.6 MiB) 353 ms n/a ¹
ORDER BY (toStartOfInterval(bucket, INTERVAL 6 HOUR), id, bucket), one part 11.8 ms (3.9 MiB) 443 ms 36.4 ms
ORDER BY (toStartOfDay(bucket), id, bucket), one part 11.5 ms (3.9 MiB) 1206 ms 12.9 ms

¹ Longer than the 4-day TTL, so the PR reads the main table.

A 512 KiB granule of the main table holds about 135 hours of one series, so a 1 h window over 200 series still reads 200 granules. Short windows outside the recent table's TTL, or with the recent table disabled, pay this cost. A time-bucket prefix avoids it without writing every sample twice or keeping 5 h partitions. The trade-off is long single-series ranges, which read one granule per time block: 7 days of one series take 36 ms instead of 6 ms with a 6 h prefix. A day prefix keeps that at 13 ms but is 3.4× slower than the recent table on the 12,800-series 6 h window.

The same held for today's row-per-sample layout on a 25-query PromQL suite over 7 days of data. Without a recent table, a time-prefixed samples key matched the recent table on the short queries (a 6 h prefix on all of them, a day prefix on the 1 h windows). The day prefix also matched it with 20 unmerged insert parts, and inserts through the TimeSeries engine took 27% less time because each sample is written once.

Limits:

  • The hand-written SQL slices with arrayFilter, while the PR uses timeSeriesSliceSortedArray, so CPU times of the bucketed layouts are pessimistic; decompressed bytes are the more robust comparison.
  • Static, merged data in a plain MergeTree.
  • The recent table used 1-hour buckets instead of the PR's 15-minute default, and kept all 7 days. Its granules hold about 13 series × 5 h with either bucket step.
  • The prefix condition was added to the WHERE explicitly: a raw bucket range does not prune an (f(bucket), id, bucket) key without Use many key columns per condition for pruning #96225. The engine generates this WHERE, so it could add the condition.

I can share the scripts to reproduce this.

@clickhouse-gh

clickhouse-gh Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Dear @nikitamikhaylov, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

@clickhouse-gh

clickhouse-gh Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

PromQL Compliance Report

Baseline: S3 master b4fae4733

Suite Baseline Current Delta
Prometheus compliance 100.00% 100.00% +0.00%
Extended support (upstream engine tests) 92.90% 93.17% +0.27%
Suite Passed Failed Unsupported
Prometheus compliance 539 -> 539 (+0) 0 -> 0 (+0) 0 -> 0 (+0)
Extended support (upstream engine tests) 680 -> 682 (+2) 18 -> 16 (-2) 34 -> 34 (+0)

Extended support (upstream engine tests): native-histogram exclusions: 149; excluded assertions: 248; upstream 3da2514eff5c.

Note: Prometheus compliance score is unchanged vs baseline.

Uploaded compliance JSON for this PR commit

@vitlibar
vitlibar added this pull request to the merge queue Oct 28, 2026
Merged via the queue into ClickHouse:master with commit fd18c2b Oct 28, 2026
352 of 355 checks passed
@vitlibar
vitlibar deleted the time-series-bucketed-samples-table branch October 28, 2026 08:27
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 28, 2026
@vitlibar

vitlibar commented Oct 28, 2026 •

Copy link
Copy Markdown
Member Author

@snelheidai, regarding to #117344 (comment): the PR was changed a lot since then and before merging, remeasure performance with your tests

@snelheidai

Copy link
Copy Markdown

Remeasured on the merge commit fd18c2b against its parent 0525e0c (CI release builds, one 4-vCPU x86 VM). The data is the same synthetic node-exporter set as before (19,800 series, 15 s interval, 7 days, 798M samples), now ending an hour before the run so that the default 4-day recent table is used, with engine defaults on both builds and merged parts. The queries are the 25-query PromQL suite from before, 7 queries over 1–7 days, and 7 short windows moved 5 days back so that they read the main table. Each query ran 7 times per build, interleaved; times are client-side latencies of the Prometheus HTTP API.

25 of the 38 valid queries are faster on the merged build (0.55–0.93×), 11 are unchanged within the 95% interval, and 2 are slower:

Query Range, series master ms merged ms merged / master [95% CI]
Q02 rate(node_network_receive_bytes_total{device="eth0"}[5m]) last 1 h, 200 42.4 37.0 0.89 [0.86, 0.93]
Q19 rate(node_cpu_seconds_total[5m]) last 1 h, 12,800 328 325 0.99 [0.96, 1.03]
Q23b sum(count_over_time(node_cpu_seconds_total[6h])) last 6 h, 12,800 402 297 0.75 [0.72, 0.78]
O02: Q02 5 days back 1 h, 200 78.4 70.5 0.88 [0.86, 0.91]
O19: Q19 5 days back 1 h, 12,800 2541 1820 0.71 [0.70, 0.73]
L5 max_over_time(node_load1{instance="host-007:9100"}[7d]) 7 d, 1 28.6 20.1 0.72 [0.69, 0.75]
L3 max by (instance) (max_over_time(node_hwmon_temp_celsius[1h])) 7 d, 800 389 210 0.55 [0.53, 0.58]
L4 sum by (job) (rate(node_network_receive_bytes_total[1h])), 15 runs 7 d, 800 541 755 1.39 [1.34, 1.45]
Q21 count({__name__=~"node_network_.*_total"}), 15 runs last 1 h, 3,200 78.9 84.8 1.07 [1.03, 1.10]

Both builds return the same series and timestamps for every query: 26 results are identical, and the 12 that sum floats in a nondeterministic order differ by at most 2.4e-14 (relative), as much as repeated runs of one build. Q23 fails on both builds because dropping __name__ leaves duplicate series.

Writes are cheaper, and storage is unchanged:

master merged
Bulk load per day of data: one INSERT of 19,800 series × 5,760 samples, data generation included 58 s, 71 s CPU 30 s, 42 s CPU
72 INSERTs of 5 minutes of data each (396k samples) 18.7 s in total, median 233 ms 15.4 s, median 197 ms
Background merges after these INSERTs 22.9 s 12.6 s
OPTIMIZE FINAL of the 7 days, main + recent 149 s 75 s
On disk, main + recent 2.44 + 1.77 GiB 2.45 + 1.77 GiB

On the table filled by these 72 INSERTs (6 main and 8 recent parts with partial buckets), 19 of the 24 short queries are faster (0.70–0.93×), 4 are unchanged and Q21 is slower (1.15× [1.03, 1.29]). The results again agree with master.

The L4 regression is in the adaptive GROUP BY, not in the read. The merged build reads 37% less for L4 (503 vs 804 MiB decompressed). But a 7-day rate state keeps its raw samples (about 0.6 MB per series), so each thread's table passes adaptive_aggregator_freeze_threshold_bytes (4 MiB) after a few series and freezes. The rows of the other series are then staged, which for bucket rows means serializing and deserializing every 240-sample Array(Tuple) element by element. serializeValueIntoMemory, deserializeAndInsertFromArena and getSerializedValueSize of ColumnTuple, ColumnArray and their element columns take about half of the CPU samples, under appendDelayedRecords in AdaptiveAggregation/Producer.cpp and the adaptive merge in Merge.cpp. On master the aggregated arguments are scalar timestamp and value columns, and turning the adaptive aggregator off changes L4 by only 4%, within noise:

L4, separate 7-run comparison master merged
defaults 548 ms 759 ms
enable_adaptive_aggregator = 0 526 ms 385 ms
adaptive_aggregator_freeze_threshold_bytes = 0 315 ms

With the byte bound off, all 9 queries in that comparison are faster on the merged build than on default master, including L4 (0.58× [0.51, 0.65]), Q21 (0.92× [0.86, 0.99]) and Q19 (0.83× [0.79, 0.87]). So turning the byte bound off for the per-series timeSeries*ToGrid aggregation in the generated SQL, or not staging rows with large array arguments, should remove both regressions.

Short windows older than the recent table's TTL (the O queries) are 0.70–0.91× of master. On both builds, the many-series ones still take 1.8–7.8× as long as the same windows inside the TTL, because a main-table granule holds about 135 hours of one series. That is the case the time-bucket prefix in my earlier comment was about; this PR does not change it.

All 38 queries (7 runs per build)
Query PromQL Range master ms merged ms merged/master [95% CI]
Q01 rate(node_network_receive_bytes_total{instance="host-001:9100",device="eth0"}[5m]) 1 h, step 15s 27.9 20.0 0.72 [0.67, 0.77]
Q02 rate(node_network_receive_bytes_total{device="eth0"}[5m]) 1 h, step 15s 42.4 37.0 0.89 [0.86, 0.93]
Q03 sum by (job) (rate(node_cpu_seconds_total{mode!="idle"}[5m])) 6 h, step 30s 1208 1091 0.91 [0.88, 0.94]
Q04 avg_over_time(node_load1[10m]) 6 h, step 30s 56.1 51.7 0.96 [0.91, 1.01]
Q05 max by (instance) (max_over_time(node_hwmon_temp_celsius[10m])) 6 h, step 30s 84.6 88.6 1.05 [0.95, 1.16]
Q06 histogram_quantile(0.99, sum by (le) (rate(http_request_duration_seconds_bucket[5m]))) 6 h, step 30s 76.4 70.8 0.95 [0.90, 1.00]
Q07 histogram_quantile(0.9, sum by (job, le) (rate(http_request_duration_seconds_bucket[5m]))) 1 h, step 15s 43.8 44.8 1.03 [0.92, 1.15]
Q08 topk(5, rate(node_disk_written_bytes_total[5m])) 1 h, step 15s 48.1 48.0 0.99 [0.83, 1.18]
Q09 count by (job, mode) (node_cpu_seconds_total) 6 h, step 30s 531 419 0.79 [0.76, 0.82]
Q10 sum by (instance) (rate(node_network_transmit_bytes_total{instance=~"host-0[0-4][0-9]:9100",device!~"lo|docker.*"}[5m])) 1 h, step 15s 42.7 35.9 0.86 [0.68, 1.08]
Q11 node_filesystem_avail_bytes{mountpoint="/"} * on(instance) group_left(nodename, release) node_uname_info 1 h, step 15s 72.8 57.1 0.85 [0.76, 0.94]
Q12 100 * (1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) 6 h, step 30s 90.7 84.3 0.93 [0.82, 1.06]
Q13 max_over_time(rate(node_network_receive_bytes_total{device="eth0"}[5m])[30m:1m]) 6 h, step 300s 63.1 49.3 0.80 [0.76, 0.85]
Q14 sum by (job) (rate(http_requests_total[5m])) instant 28.8 23.1 0.80 [0.77, 0.84]
Q15 topk(10, max_over_time(node_load1[1h])) instant 30.0 25.6 0.87 [0.84, 0.91]
Q16 predict_linear(node_filesystem_avail_bytes{mountpoint="/data"}[1h], 4 * 3600) instant 36.1 28.0 0.84 [0.72, 0.97]
Q17 sum(increase(node_context_switches_total[1h])) instant 27.1 25.0 0.95 [0.80, 1.13]
Q18 sum(rate(node_cpu_seconds_total[5m])) 6 h, step 30s 1333 1208 0.91 [0.90, 0.92]
Q19 rate(node_cpu_seconds_total[5m]) 1 h, step 60s 328 325 0.99 [0.96, 1.03]
Q20 quantile_over_time(0.95, node_load1[30m]) 6 h, step 30s 95.1 90.9 0.97 [0.88, 1.07]
Q21 count({__name__=~"node_network_.*_total"}) 1 h, step 15s 83.6 89.1 1.07 [1.00, 1.13]
Q22 sum by (job) (rate(http_requests_total{code="500"}[5m])) / sum by (job) (rate(http_requests_total[5m])) 6 h, step 30s 94.8 88.2 0.93 [0.90, 0.97]
Q23b sum(count_over_time(node_cpu_seconds_total[6h])) instant 402 296 0.75 [0.72, 0.78]
Q24 max_over_time(node_load1[5m]) 6 h, step 15s 64.9 64.4 0.99 [0.93, 1.05]
L1 rate(node_network_receive_bytes_total{instance="host-001:9100",device="eth0"}[5m]) 6.95833 d, step 300s 29.5 21.5 0.73 [0.70, 0.75]
L2 rate(node_cpu_seconds_total{instance="host-010:9100",cpu="0",mode="user"}[5m]) 1 d, step 60s 35.9 24.0 0.67 [0.64, 0.69]
L3 max by (instance) (max_over_time(node_hwmon_temp_celsius[1h])) 6.95833 d, step 3600s 389 210 0.55 [0.53, 0.58]
L4 sum by (job) (rate(node_network_receive_bytes_total[1h])) 6.95833 d, step 3600s 561 744 1.32 [1.29, 1.35]
L5 max_over_time(node_load1{instance="host-007:9100"}[7d]) instant 28.6 20.1 0.72 [0.69, 0.75]
L6 sum(rate(node_context_switches_total[5m])) 1 d, step 60s 82.3 75.6 0.92 [0.88, 0.95]
L7 avg_over_time(node_load1{job="node-prod"}[15m]) 6.95833 d, step 900s 69.5 57.9 0.81 [0.76, 0.85]
O01 rate(node_network_receive_bytes_total{instance="host-001:9100",device="eth0"}[5m]) 1 h, step 15s 27.9 20.0 0.70 [0.68, 0.73]
O02 rate(node_network_receive_bytes_total{device="eth0"}[5m]) 1 h, step 15s 78.4 70.5 0.88 [0.86, 0.91]
O03 sum by (job) (rate(node_cpu_seconds_total{mode!="idle"}[5m])) 6 h, step 30s 2622 2379 0.91 [0.85, 0.96]
O14 sum by (job) (rate(http_requests_total[5m])) instant 80.7 57.4 0.71 [0.67, 0.75]
O17 sum(increase(node_context_switches_total[1h])) instant 74.8 58.8 0.79 [0.76, 0.82]
O19 rate(node_cpu_seconds_total[5m]) 1 h, step 60s 2541 1820 0.71 [0.70, 0.73]
O23b sum(count_over_time(node_cpu_seconds_total[6h])) instant 2578 2202 0.85 [0.83, 0.86]
The storage-level reads from my earlier comment, on the real tables

Same hand-written SQL as before: count and sum of the selected series' samples in the window, with arrayFilter over the bucket arrays. Server-side medians of 10 interleaved runs, decompressed bytes in parentheses:

Table 200 series, 1 h 12,800 series, 6 h 1 series, 7 days
merged main 95.5 ms (100 MiB) 1811 ms 7.7 ms
merged recent 10.1 ms (4.3 MiB) 190 ms n/a
master main 41.3 ms (163 MiB) 1836 ms 10.6 ms
master recent 7.3 ms (7.3 MiB) 199 ms n/a

The September emulation of the PR's main table measured 195 ms, 6075 ms and 6.3 ms there (another VM, an older build, ZSTD(3)-only codecs). The PromQL selector does not use arrayFilter, so the end-to-end tables above are the better comparison.

valerypetrov added a commit to valerypetrov/ClickHouse that referenced this pull request Oct 28, 2026
Since ClickHouse#117344 the samples table of a new TimeSeries table stores buckets of
samples, so timeSeriesData() has no `value` column any more and the test
failed with "Identifier 'data.value' cannot be resolved". Read the value
from the `samples` array instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
valerypetrov added a commit to valerypetrov/ClickHouse that referenced this pull request Oct 29, 2026
Since ClickHouse#117344 timeSeriesSelector requires its return_columns argument, so the test failed after the merge with master. 'timestamp_and_value' gives the columns the test read before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
valerypetrov added a commit to valerypetrov/ClickHouse that referenced this pull request Oct 29, 2026
Since ClickHouse#117344 timeSeriesSelector requires its return_columns argument, so the test failed after the merge with master. 'timestamp_and_value' gives the rows the test counted before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
valerypetrov added a commit to valerypetrov/ClickHouse that referenced this pull request Oct 29, 2026
…ential-smoothing

Master's ClickHouse#117344 replaced the raw-data store method RAW_DATA with SAMPLES and TIMESTAMP_AND_VALUE,
so the factor switch of double_exponential_smoothing names the two new store methods.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
valerypetrov added a commit to valerypetrov/ClickHouse that referenced this pull request Oct 29, 2026
…d-window

Master's ClickHouse#117344 split the raw-data store method into SAMPLES (bucketed tables, now the default) and
TIMESTAMP_AND_VALUE (tables of version 10 and earlier). The fused metric-name drop now applies to both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 2, 2026
ClickHouse#117344 switched the samples inner table to the bucketed schema of version 11
(id, samples, bucket, min_time, max_time), so the fixture's
`INSERT INTO FUNCTION timeSeriesSamples(ts) SELECT id, timestamp, value ...`
fails on current master with NUMBER_OF_COLUMNS_DOESNT_MATCH (source: 3 and
result: 5). Insert the samples through the TimeSeries table instead, which
works with every samples layout. The reference is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 5, 2026
Since ClickHouse#117344 a TimeSeries table of the latest version (11) stores buckets
of samples and requires an engine of the AggregatingMergeTree family for its
samples table, so `SAMPLES ENGINE = File(Parquet)` is rejected with
INCORRECT_QUERY and the test failed on every run against current master
(the merge queue flaky check of this PR).

Version 7, the latest one on this branch's base and still supported on
master, stores one sample per row in any engine, so the arm keeps all three
targets in File(Parquet) and the same queries on both trees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
marco-vb pushed a commit to marco-vb/ClickHouse that referenced this pull request Nov 16, 2026
A row of the samples table holds one hour of one series (ClickHouse#117344), so with
`index_granularity_bytes = 524288` a granule is about 135 hours of one 15 s
series and a short PromQL window older than the recent samples table reads
whole granules. Change the default of `samples_index_granularity_bytes` to
262144 and update its documentation and the tests that check the default.

Measured on the CI amd_release binary of 9b41283 with the data set of
ClickHouse#131459 (19,800 series, 14 days, byte counters with random decimals),
max_threads = 4, 15 interleaved reps, ratio = 262144 / 524288:
- O19 rate(node_cpu_seconds_total[5m]), 1 h range 5 days back: 0.670
- O23b sum(count_over_time(node_cpu_seconds_total[6h])): 0.696
- W1 / W3 / F4 / F6 long scans: 1.170 / 1.140 / 1.181 / 1.266
- marks 49,282 -> 99,299, samples table on disk +1.0%

Existing tables keep their stored `index_granularity_bytes`. The setting
exists only on master, so no compatibility handling is needed.

Adds the perf test promql_selector_old_short_window.xml.

Closes: ClickHouse#131459

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-promql PromQL / time-series subsystem: TimeSeries storage engine, PromQL parser, PromQL-to-SQL converter... pr-experimental Experimental Feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants