Repository navigation
fix(app): keep search counts exact when a materialized view serves the chart - #3738
Draft
alex-fedotyev wants to merge 2 commits into
Draft
alex-fedotyev wants to merge 2 commits into
alex-fedotyev wants to merge 2 commits into
Conversation
…e chart The search page asks for the exact selected range so the histogram and the results count match the results table (#2256). When a materialized view served those queries, the optimizer widened the range to whole view buckets, so counts included rows from outside the selection: about 1.7% more spans on a one-hour window on the demo data, and much more for bursty series. For requests with alignDateRangeToGranularity: false, the partial first and last chart buckets are now read from the source table with the exact bounds, and only the whole buckets in between from the view. Each bucket still comes from a single table, so counts, averages and percentiles all stay exact. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 70ea21e The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
Contributor
E2E Test Results✅ All tests passed • 474 passed • 1 skipped • 1095s
Tests ran across 4 shards in parallel. |
…nd its table A materialized view names an unaliased aggregate after its merge expression (SUM(...) of the view's count column), while the source table returns count(). With the partial edge buckets read from the source table and the rest from the view, the same series came back under two names, so the search histogram drew the view's buckets as the wrong series and the results count missed them. Chunks now take the first chunk's column names, by position: both queries are built from the same select list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch was successfully deployed
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.
Stack
Layer 3 of 5 in a GitHub stack (stack #3741). GitHub shows each layer's base as the branch below it, but the stack's base is
main: merging any PR lands it and every PR below it onmain, one squashed commit each. Each PR's diff is only its own layer, and CI runs as if each targetsmain:The layers are independent fixes to how charts read materialized views, ordered so the smallest land first. They prepare for a default trace rollup, which comes in a follow-up stack.
Summary
The search page queries the histogram and the results count with the exact selected range, so the count matches the rows in the results table (#2256). When a source has a materialized view that fits, the optimizer widens that range to whole view buckets, and the counts include rows from outside the selection. On a one-hour window over the demo spans that was 3,111,654 spans instead of 3,059,550, and bursty series drift much more: in one window the error count read 30% high because an error burst sat in the partial first minute. The trace search RED charts run the same queries.
For requests with
alignDateRangeToGranularity: false,useQueriedChartConfignow splits the query:Each bucket still comes from a single table, so counts, averages and percentiles all stay exact. The view names an unaliased aggregate after its own merge expression (
SUM(...)over its count column, where the source table returnscount()), so every chunk takes the first chunk's column names, by position: both queries come from the same select list. The extra raw scan is at most two chart buckets, and a range shorter than one whole bucket reads the source table alone. Aligned charts, such as dashboard tiles, are unchanged.Test plan
getQueryWindows): no view, an aligned request, an exact request with partial edges, a range shorter than a bucket, a range on bucket boundaries, an inclusive end on a boundary, and a chunked day with contiguous windows.ci:lintand unit tests.Part of HDX-6120.