Skip to content

Commit b68a4c9

Browse files
ensure that only one limit is used on query (#1221)
1 parent 62eddcf commit b68a4c9

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

.changeset/famous-yaks-cough.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@hyperdx/common-utils": patch
3+
"@hyperdx/app": patch
4+
---
5+
6+
Tweak getMapKeys to leverage one row limiting implementation

packages/app/src/components/DBSearchPageFilters.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,16 @@ const DBSearchPageFiltersComponent = ({
559559
usePinnedFilters(sourceId ?? null);
560560
const { width, startResize } = useResizable(16, 'left');
561561

562-
const { data: jsonColumns } = useJsonColumns(tcFromChartConfig(chartConfig));
563-
const { data, isLoading, error } = useAllFields(
564-
tcFromChartConfig(chartConfig),
565-
);
562+
const { data: jsonColumns } = useJsonColumns({
563+
databaseName: chartConfig.from.databaseName,
564+
tableName: chartConfig.from.tableName,
565+
connectionId: chartConfig.connection,
566+
});
567+
const { data, isLoading, error } = useAllFields({
568+
databaseName: chartConfig.from.databaseName,
569+
tableName: chartConfig.from.tableName,
570+
connectionId: chartConfig.connection,
571+
});
566572

567573
const { data: source } = useSource({ id: sourceId });
568574
const { data: tableMetadata } = useTableMetadata(tcFromSource(source));

packages/common-utils/src/__tests__/metadata.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,9 @@ describe('Metadata', () => {
280280
expect(mockClickhouseClient.query).toHaveBeenCalledWith(
281281
expect.objectContaining({
282282
clickhouse_settings: {
283-
max_rows_to_read: String(3e6),
284-
read_overflow_mode: 'break',
283+
max_rows_to_read: '0',
284+
timeout_overflow_mode: 'break',
285+
max_execution_time: 15,
285286
},
286287
}),
287288
);
@@ -312,8 +313,9 @@ describe('Metadata', () => {
312313
expect(mockClickhouseClient.query).toHaveBeenCalledWith(
313314
expect.objectContaining({
314315
clickhouse_settings: {
315-
max_rows_to_read: String(3e6),
316-
read_overflow_mode: 'break',
316+
max_rows_to_read: '0',
317+
timeout_overflow_mode: 'break',
318+
max_execution_time: 15,
317319
},
318320
}),
319321
);

packages/common-utils/src/metadata.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ export class Metadata {
313313
query_params: sql.params,
314314
connectionId,
315315
clickhouse_settings: {
316-
max_rows_to_read: String(
317-
this.getClickHouseSettings().max_rows_to_read ??
318-
DEFAULT_METADATA_MAX_ROWS_TO_READ,
319-
),
320-
read_overflow_mode: 'break',
321316
...this.getClickHouseSettings(),
317+
// Max 15 seconds to get keys
318+
timeout_overflow_mode: 'break',
319+
max_execution_time: 15,
320+
// Set the value to 0 (unlimited) so that the LIMIT is used instead
321+
max_rows_to_read: '0',
322322
},
323323
})
324324
.then(res => res.json<Record<string, unknown>>())
@@ -642,12 +642,12 @@ export class Metadata {
642642
connectionId: chartConfig.connection,
643643
clickhouse_settings: !disableRowLimit
644644
? {
645-
max_rows_to_read: String(
646-
this.getClickHouseSettings().max_rows_to_read ??
647-
DEFAULT_METADATA_MAX_ROWS_TO_READ,
648-
),
649-
read_overflow_mode: 'break',
650645
...this.getClickHouseSettings(),
646+
// Max 15 seconds to get keys
647+
timeout_overflow_mode: 'break',
648+
max_execution_time: 15,
649+
// Set the value to 0 (unlimited) so that the LIMIT is used instead
650+
max_rows_to_read: '0',
651651
}
652652
: undefined,
653653
})

0 commit comments

Comments
 (0)