refactor(perf): offload metric ratio computation to native ClickHouse CTE#2681
refactor(perf): offload metric ratio computation to native ClickHouse CTE#2681Aryainguz wants to merge 10 commits into
Conversation
🦋 Changeset detectedLatest commit: afe1fd7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@Aryainguz is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR moves metric ratio calculation into a native ClickHouse query path. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (9): Last reviewed commit: "Merge branch 'main' into feat/native-cli..." | Re-trigger Greptile |
…/native-clickhouse-ratios
Deep Review✅ No critical issues found. The new native-CTE ratio path is SQL-injection-safe — every user-influenceable value ( 🟡 P2 -- recommended
🔵 P3 nitpicks (4)
Reviewers (12): correctness, testing, maintainability, project-standards, security, performance, api-contract, reliability, kieran-typescript, adversarial, agent-native, learnings. Testing gaps: No test asserts the new native-CTE output equals the legacy in-memory output for the same input; zero/one-sided-denominator behavior ( |
… ratio select clause
…ng suffix to duplicate q1 aliases
…g processing for ratio-based queries
…o FULL OUTER JOIN in ClickHouse queries
|
@pulpdrew please review once |
Summary
the metric ratios computation in @hyperdx/common-utils to execute natively inside ClickHouse via CTEs instead of fetching two separate streams and zipping them in memory using Node.js. Updated tests, changeset file as per the changes.
Why this change was made:
Currently, when evaluating metric ratio charts (e.g. dividing the sum of one metric by the sum of another), the backend executes two separate queries concurrently. The results are then loaded entirely into Node.js memory, zipped by their respective series, and the mathematical ratio calculation is executed sequentially in JavaScript.
For heavy, high-cardinality charts such as time series distributions across thousands of service.names this leads to:
Fixes #2680
Local Validations:


