Skip to content

Commit e1c8f83

Browse files
fix(Overview): use stats from describe for all column tables (#1026)
1 parent 9d198c5 commit e1c8f83

File tree

5 files changed

+33
-132
lines changed

5 files changed

+33
-132
lines changed

src/containers/Tenant/Diagnostics/Overview/Overview.tsx

+1-22
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ interface OverviewProps {
3131
function Overview({type, path}: OverviewProps) {
3232
const [autoRefreshInterval] = useAutoRefreshInterval();
3333

34-
// FIXME: The request is too heavy, stats table may have millions of items
35-
// Disabled until fixed
36-
// https://github.com/ydb-platform/ydb-embedded-ui/issues/907
37-
// https://github.com/ydb-platform/ydb-embedded-ui/issues/908
38-
// const olapParams = isTableType(type) && isColumnEntityType(type) ? {path} : skipToken;
39-
// const {currentData: olapData, isFetching: olapIsFetching} = olapApi.useGetOlapStatsQuery(
40-
// olapParams,
41-
// {pollingInterval: autoRefreshInterval},
42-
// );
43-
// const olapStatsLoading = olapIsFetching && olapData === undefined;
44-
// const {result: olapStats} = olapData || {result: undefined};
45-
4634
const isEntityWithMergedImpl = isEntityWithMergedImplementation(type);
4735

4836
// shallowEqual prevents rerenders when new schema data is loaded
@@ -70,7 +58,6 @@ function Overview({type, path}: OverviewProps) {
7058

7159
const {error: schemaError} = useGetSchemaQuery({path});
7260

73-
// overviewLoading || olapStatsLoading
7461
const entityLoading = overviewLoading;
7562
const entityNotReady = isEntityWithMergedImpl && !mergedChildrenPaths;
7663

@@ -97,15 +84,7 @@ function Overview({type, path}: OverviewProps) {
9784
[EPathType.EPathTypeReplication]: () => <AsyncReplicationInfo data={data} />,
9885
};
9986

100-
return (
101-
(type && pathTypeToComponent[type]?.()) || (
102-
<TableInfo
103-
data={data}
104-
type={type}
105-
// olapStats={olapStats}
106-
/>
107-
)
108-
);
87+
return (type && pathTypeToComponent[type]?.()) || <TableInfo data={data} type={type} />;
10988
};
11089

11190
if (entityLoading || entityNotReady) {

src/containers/Tenant/Diagnostics/Overview/TableInfo/TableInfo.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22

33
import {InfoViewer} from '../../../../../components/InfoViewer';
4-
import type {KeyValueRow} from '../../../../../types/api/query';
54
import type {EPathType, TEvDescribeSchemeResult} from '../../../../../types/api/schema';
65
import {cn} from '../../../../../utils/cn';
76
import {EntityTitle} from '../../../EntityTitle/EntityTitle';
@@ -16,18 +15,17 @@ const b = cn('ydb-diagnostics-table-info');
1615
interface TableInfoProps {
1716
data?: TEvDescribeSchemeResult;
1817
type?: EPathType;
19-
olapStats?: KeyValueRow[];
2018
}
2119

22-
export const TableInfo = ({data, type, olapStats}: TableInfoProps) => {
20+
export const TableInfo = ({data, type}: TableInfoProps) => {
2321
const title = <EntityTitle data={data?.PathDescription} />;
2422

2523
const {
2624
generalInfo,
2725
tableStatsInfo,
2826
tabletMetricsInfo = [],
2927
partitionConfigInfo = [],
30-
} = React.useMemo(() => prepareTableInfo(data, type, olapStats), [data, type, olapStats]);
28+
} = React.useMemo(() => prepareTableInfo(data, type), [data, type]);
3129

3230
return (
3331
<div className={b()}>

src/containers/Tenant/Diagnostics/Overview/TableInfo/prepareTableInfo.ts

+28-65
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
formatTableStatsItem,
77
formatTabletMetricsItem,
88
} from '../../../../../components/InfoViewer/formatters';
9-
import type {KeyValueRow} from '../../../../../types/api/query';
109
import type {
1110
TColumnDataLifeCycle,
1211
TColumnTableDescription,
@@ -17,34 +16,12 @@ import type {
1716
import {EPathType} from '../../../../../types/api/schema';
1817
import {formatBytes, formatNumber} from '../../../../../utils/dataFormatters/dataFormatters';
1918
import {formatDurationToShortTimeFormat} from '../../../../../utils/timeParsers';
20-
import {isNumeric} from '../../../../../utils/utils';
2119

2220
const isInStoreColumnTable = (table: TColumnTableDescription) => {
2321
// SchemaPresetId could be 0
2422
return table.SchemaPresetName && table.SchemaPresetId !== undefined;
2523
};
2624

27-
const prepareOlapStats = (olapStats: KeyValueRow[]) => {
28-
const Bytes = olapStats?.reduce((acc, el) => {
29-
const value = isNumeric(el.Bytes) ? Number(el.Bytes) : 0;
30-
return acc + value;
31-
}, 0);
32-
const Rows = olapStats?.reduce((acc, el) => {
33-
const value = isNumeric(el.Rows) ? Number(el.Rows) : 0;
34-
return acc + value;
35-
}, 0);
36-
const tabletIds = olapStats?.reduce((acc, el) => {
37-
acc.add(el.TabletId);
38-
return acc;
39-
}, new Set());
40-
41-
return [
42-
{label: 'PartCount', value: tabletIds?.size ?? 0},
43-
{label: 'RowCount', value: formatNumber(Rows) ?? 0},
44-
{label: 'DataSize', value: formatBytes(Bytes) ?? 0},
45-
];
46-
};
47-
4825
const prepareTTL = (ttl: TTTLSettings | TColumnDataLifeCycle) => {
4926
// ExpireAfterSeconds could be 0
5027
if (ttl.Enabled && ttl.Enabled.ColumnName && ttl.Enabled.ExpireAfterSeconds !== undefined) {
@@ -143,11 +120,7 @@ const prepareTableGeneralInfo = (PartitionConfig: TPartitionConfig, TTLSettings?
143120
};
144121

145122
/** Prepares data for Table, ColumnTable and ColumnStore */
146-
export const prepareTableInfo = (
147-
data?: TEvDescribeSchemeResult,
148-
type?: EPathType,
149-
olapStats?: KeyValueRow[],
150-
) => {
123+
export const prepareTableInfo = (data?: TEvDescribeSchemeResult, type?: EPathType) => {
151124
if (!data) {
152125
return {};
153126
}
@@ -199,43 +172,33 @@ export const prepareTableInfo = (
199172
}
200173
}
201174

202-
let tableStatsInfo: InfoViewerItem[][] | undefined;
203-
204-
// There is no TableStats and TabletMetrics for ColumnTables inside ColumnStore
205-
// Therefore we parse olapStats
206-
if (type === EPathType.EPathTypeColumnTable && isInStoreColumnTable(ColumnTableDescription)) {
207-
if (olapStats) {
208-
tableStatsInfo = [prepareOlapStats(olapStats)];
209-
}
210-
} else {
211-
tableStatsInfo = [
212-
formatObject(formatTableStatsItem, {
213-
PartCount,
214-
RowCount,
215-
DataSize,
216-
IndexSize,
217-
}),
218-
formatObject(formatTableStatsItem, {
219-
LastAccessTime,
220-
LastUpdateTime,
221-
}),
222-
formatObject(formatTableStatsItem, {
223-
ImmediateTxCompleted,
224-
PlannedTxCompleted,
225-
TxRejectedByOverload,
226-
TxRejectedBySpace,
227-
TxCompleteLagMsec,
228-
InFlightTxCount,
229-
}),
230-
formatObject(formatTableStatsItem, {
231-
RowUpdates,
232-
RowDeletes,
233-
RowReads,
234-
RangeReads,
235-
RangeReadRows,
236-
}),
237-
];
238-
}
175+
const tableStatsInfo = [
176+
formatObject(formatTableStatsItem, {
177+
PartCount,
178+
RowCount,
179+
DataSize,
180+
IndexSize,
181+
}),
182+
formatObject(formatTableStatsItem, {
183+
LastAccessTime,
184+
LastUpdateTime,
185+
}),
186+
formatObject(formatTableStatsItem, {
187+
ImmediateTxCompleted,
188+
PlannedTxCompleted,
189+
TxRejectedByOverload,
190+
TxRejectedBySpace,
191+
TxCompleteLagMsec,
192+
InFlightTxCount,
193+
}),
194+
formatObject(formatTableStatsItem, {
195+
RowUpdates,
196+
RowDeletes,
197+
RowReads,
198+
RangeReads,
199+
RangeReadRows,
200+
}),
201+
];
239202

240203
//@ts-expect-error
241204
const tabletMetricsInfo = formatObject(formatTabletMetricsItem, TabletMetrics);

src/store/reducers/olapStats.ts

-39
This file was deleted.

src/types/api/schema/columnEntity.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ export interface TColumnTableDescription {
66
Schema?: TColumnTableSchema;
77
TtlSettings?: TColumnDataLifeCycle;
88

9-
SchemaPresetId?: number;
10-
SchemaPresetName?: string;
9+
SchemaPresetId?: number; // For in-store column tables, could be 0
10+
SchemaPresetName?: string; // For in-store column tables
1111

1212
ColumnStorePathId?: TPathID;
1313

0 commit comments

Comments
 (0)