Skip to content

Commit 3feb3b2

Browse files
authored
chore(frontend): better UX for running queries page (#59)
* chore(frontend): change the way render of reloading running queries * chore: format reable row count for running queries table
1 parent bf61a8e commit 3feb3b2

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

frontend/src/pages/RunningQueries/RunningQueries.tsx

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Table, Button, notification, Typography } from 'antd'
1+
import { Table, Button, notification, Typography, Tooltip, Spin } from 'antd'
22
import { usePollingEffect } from '../../utils/usePollingEffect'
33
import React, { useState } from 'react'
44
import { ColumnType } from 'antd/es/table'
@@ -8,8 +8,10 @@ const { Paragraph } = Typography
88
interface RunningQueryData {
99
query: string
1010
read_rows: number
11+
read_rows_readable: string
1112
query_id: string
1213
total_rows_approx: number
14+
total_rows_approx_readable: string
1315
elapsed: number
1416
memory_usage: string
1517
}
@@ -80,11 +82,16 @@ export default function RunningQueries() {
8082
)
8183
},
8284
},
85+
{ title: 'User', dataIndex: 'user' },
8386
{ title: 'Elapsed time', dataIndex: 'elapsed' },
8487
{
8588
title: 'Rows read',
8689
dataIndex: 'read_rows',
87-
render: (_: any, item) => `~${item.read_rows}/${item.total_rows_approx}`,
90+
render: (_: any, item) => (
91+
<Tooltip title={`~${item.read_rows}/${item.total_rows_approx}`}>
92+
~{item.read_rows_readable}/{item.total_rows_approx_readable}
93+
</Tooltip>
94+
),
8895
},
8996
{ title: 'Memory Usage', dataIndex: 'memory_usage' },
9097
{
@@ -95,7 +102,6 @@ export default function RunningQueries() {
95102

96103
usePollingEffect(
97104
async () => {
98-
setRunningQueries([])
99105
setLoadingRunningQueries(true)
100106
const res = await fetch('/api/analyze/running_queries')
101107
const resJson = await res.json()
@@ -108,9 +114,13 @@ export default function RunningQueries() {
108114

109115
return (
110116
<>
111-
<h1 style={{ textAlign: 'left' }}>Running queries</h1>
117+
<h1 style={{ textAlign: 'left' }}>Running queries {loadingRunningQueries ? <Spin /> : null}</h1>
112118
<br />
113-
<Table columns={columns} dataSource={runningQueries} loading={loadingRunningQueries} />
119+
<Table
120+
columns={columns}
121+
dataSource={runningQueries}
122+
loading={runningQueries.length == 0 && loadingRunningQueries}
123+
/>
114124
</>
115125
)
116126
}

housewatch/clickhouse/queries/sql.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,16 @@
176176
"""
177177

178178
RUNNING_QUERIES_SQL = """
179-
SELECT query, elapsed, read_rows, total_rows_approx, formatReadableSize(memory_usage) AS memory_usage, query_id
179+
SELECT
180+
query,
181+
user,
182+
elapsed,
183+
read_rows,
184+
formatReadableQuantity(read_rows) AS read_rows_readable,
185+
total_rows_approx,
186+
formatReadableQuantity(total_rows_approx) AS total_rows_approx_readable,
187+
formatReadableSize(memory_usage) AS memory_usage,
188+
query_id
180189
FROM system.processes
181190
WHERE Settings['log_comment'] != 'running_queries_lookup'
182191
ORDER BY elapsed DESC

0 commit comments

Comments
 (0)