Skip to content

perf(ch): serve latest-state and summary queries from precomputed tables#298

Merged
zer0stars merged 4 commits into
mainfrom
feat/signal-latest-reads
Jun 11, 2026
Merged

perf(ch): serve latest-state and summary queries from precomputed tables#298
zer0stars merged 4 commits into
mainfrom
feat/signal-latest-reads

Conversation

@zer0stars

Copy link
Copy Markdown
Member

Summary

  • signalsLatest / signalsSnapshot / lastSeen / availableSignals now read the precomputed signal_latest table (ReplacingMergeTree, model-garage 00010) instead of fanning out across every part of the ~97B-row signal table.
  • dataSummary per-name count/first-seen/last-seen now read signal_summary/event_summary (AggregatingMergeTree, model-garage 00011).
  • Location fields read kind=1 rows (pre-filtered non-(0,0) fixes) — plain argMax replaces argMaxIf, same semantics.
  • Readers aggregate at query time (argMax/max/sum/min); never FINAL — exact regardless of merge state.
  • Removes TestLatestQueriesUseProjection (asserted the projections being dropped in model-garage 00012).

Evidence (prod, 2026-06-11)

Projections are stored per part, so latest-state reads inherit the ~140-part fan-out: signalsLatest via projection p50 = 2995ms (31,467 queries/day) vs raw primary-key reads p50 = 110ms. Point lookups on signal_latest target single-digit ms.

Rollout (order matters)

  1. model-garage feat(migrations): signal_latest + summary tables (v1.0.13) model-garage#263 merged + tagged v1.0.13 (00010+00011).
  2. Prod migration job runs @v1.0.13; operator runs the 4 backfill INSERTs (SQL in migration comments).
  3. Then this PR deploys (re-pin go.mod to v1.0.13 tag before merge).
  4. After 24h soak + query_log gate: model-garage feat(migrations): drop per-part latest projections (v1.0.14 — HOLD until telemetry-api switch + 24h soak) model-garage#264 (00012 drop projections) = v1.0.14.

Test plan

  • Shape unit tests for all rewritten builders (signal_latest / kind filters / summary tables).
  • Full ch container suite + e2e pass (migrations 00010/00011 applied in testcontainer; inserts flow through the new MVs, so behavior tests exercise the new read paths).
  • make lint: 0 issues.

Pinned to the feat/signal-latest-table branch head (pre-v1.0.13
pseudo-version); re-pin to the v1.0.13 tag once released.
signalsLatest/signalsSnapshot/lastSeen/availableSignals now read the
precomputed signal_latest table (model-garage 00010) instead of
fanning out across every part of the raw signal table. Location
fields read kind=1 rows, which pre-filter (0,0) fixes, so plain
argMax replaces argMaxIf. Supersedes the projection-matching shapes
from #284/#297.

dataSummary per-name count/first-seen/last-seen now read the
AggregatingMergeTree summary tables (model-garage 00011) instead of
aggregating the raw tables. Counts are over raw inserts, matching the
approximation of the previous non-FINAL count(*) reads.
…istency

Scanning is positional so agg_location worked, but the non-location
branch of the latest UNION ALL aliases its zero tuple value_location;
matching aliases keep the result shape self-describing.
@zer0stars zer0stars merged commit 083127e into main Jun 11, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant