Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/heatmap-filters-skip-column-refetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperdx/app': patch
---

fix: Don't refetch the trace heatmap or filter values when a table column is added or removed
45 changes: 29 additions & 16 deletions packages/app/src/DBSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2160,12 +2160,29 @@ function DBSearchPageContent() {
? searchedSource
: null;

const histogramGroupBy = resolveSearchGroupBy(groupByParam, searchedSource);

// The histogram, trace heatmap and filter queries don't select the table's
// columns, so they only take the aliases they use. The rest would refetch
// them whenever a column is added or removed. Everything but the table's
// select and sort can reference an alias, including the body, timestamp and
// sample-weight expressions.
const referencedAliasWith = useMemo(
() =>
chartConfig == null
? undefined
: getReferencedWithClauses(aliasWith, [
JSON.stringify({ ...chartConfig, select: '', orderBy: '' }),
histogramGroupBy ?? '',
]),
[chartConfig, aliasWith, histogramGroupBy],
);

const histogramTimeChartConfig = useMemo(() => {
if (chartConfig == null) {
return undefined;
}

const groupBy = resolveSearchGroupBy(groupByParam, searchedSource);
return {
...chartConfig,
select: [
Expand All @@ -2179,12 +2196,7 @@ function DBSearchPageContent() {
granularity: 'auto',
dateRange: searchedTimeRange,
displayType: DisplayType.StackedBar,
// Everything but the table's select and sort can reference an alias,
// including the body, timestamp and sample-weight expressions.
with: getReferencedWithClauses(aliasWith, [
JSON.stringify({ ...chartConfig, select: '', orderBy: '' }),
groupBy ?? '',
]),
with: referencedAliasWith,
// Preserve the original table select string for "View Events" links.
// convertToTimeChartConfig drops it from the query key.
eventTableSelect: searchedConfig.select ?? undefined,
Expand All @@ -2197,15 +2209,14 @@ function DBSearchPageContent() {
alignDateRangeToGranularity: false,
// Make sure the end date is inclusive so that the histogram and table counts match
dateRangeEndInclusive: true,
groupBy,
groupBy: histogramGroupBy,
} satisfies BuilderChartConfigWithDateRange;
}, [
chartConfig,
searchedSource,
aliasWith,
referencedAliasWith,
searchedTimeRange,
searchedConfig.select,
groupByParam,
histogramGroupBy,
]);

// The default severity/status grouping reads without a legend.
Expand Down Expand Up @@ -2246,9 +2257,9 @@ function DBSearchPageContent() {
...chartConfig,
orderBy: undefined,
dateRange: searchedTimeRange,
with: aliasWith,
with: referencedAliasWith,
} satisfies BuilderChartConfigWithDateRange),
[chartConfig, searchedTimeRange, aliasWith],
[chartConfig, searchedTimeRange, referencedAliasWith],
);

// While the heatmap shows, live tail stays off as in delta and pattern modes:
Expand Down Expand Up @@ -2329,10 +2340,13 @@ function DBSearchPageContent() {
);

const filtersChartConfig = useMemo<BuilderChartConfigWithDateRange>(() => {
// The filter queries set their own select, so the table's would only
// change their query keys.
const overrides = {
select: '',
orderBy: undefined,
dateRange: searchedTimeRange,
with: aliasWith,
with: referencedAliasWith,
} as const;
return chartConfig
? {
Expand All @@ -2347,10 +2361,9 @@ function DBSearchPageContent() {
tableName: '',
},
where: '',
select: '',
...overrides,
};
}, [chartConfig, searchedTimeRange, aliasWith]);
}, [chartConfig, searchedTimeRange, referencedAliasWith]);

const openNewSourceModal = useCallback(() => {
setNewSourceModalOpened(true);
Expand Down
Loading