perf(querier): classify time-series columns once per query - #12611
Open
tushar-signoz wants to merge 1 commit into
Open
perf(querier): classify time-series columns once per query#12611tushar-signoz wants to merge 1 commit into
tushar-signoz wants to merge 1 commit into
Conversation
The time-series reader decided what each cell was by switching on its pointer type, per cell per row — and the switch listed 32- and 64-bit widths only, so a raw ClickHouse query aggregating or grouping by an Int8, UInt8, Int16, UInt16 or Bool column (max(severity_number), GROUP BY has_error) either emptied the chart or merged every group into one unlabelled series. Classify each column once, up front, into what it contributes to every row: timestamp, numeric, bool, string, or document. Numeric coverage now comes from the same helper that counts numeric columns, so the two cannot disagree, and any width works. Rows reuse the scratch that used to be allocated per row — the aggregation map, the label slices, and the label objects for rows that land in existing series — and values dodge the reflection boxing on the way out of the driver. On a 200k-series group-by this is a quarter fewer bytes allocated and a fifth less CPU per request. The __result_<n> index is now also bounded before it sizes the aggregation slots: the alias is user-written in raw SQL, and an overflowing or huge index panicked the reader — on main too, where the bucket slice is sized from the same number after the rows are read.
tushar-signoz
requested review from
srikanthccv and
therealpandey
as code owners
August 18, 2026 22:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Stacked on #12555 — the first commit here is that PR; review only the
perf(querier)commit.The graph reader decided what each result column was by switching on its Go pointer type, for every cell of every row — and the switch only listed 32- and 64-bit numeric widths. Anything narrower fell through and was silently dropped, so a raw ClickHouse panel aggregating or grouping by a small-integer or boolean column (
max(severity_number),GROUP BY has_error,kind) either rendered an empty chart or merged every group into one unlabelled line.__result_<n>index is bounded before it sizes anything. The alias is user-written in raw SQL, and an overflowing or huge index (__result_99999999999999999999) crashed the reader with a panic — onmaintoo, where the result buckets are sized from the same number after the rows are read. Indices past 1000 are now read as plain numeric columns.Additional Information
Behaviour before/after, raw SQL panels on a 1M-row stack:
max(severity_number)over time (UInt8)severity_numbercount() AS __result_99999999999999999999Cost, measured per request on a
GROUP BY trace_idquery returning 200k series, from pprof allocation deltas on a live server: 25% fewer bytes allocated and 23% less CPU (35% fewer allocations inside the reader itself). Response time is unchanged — these queries are dominated by ClickHouse and by encoding the response.