@@ -151,28 +151,28 @@ SELECT database, table, count(*) AS parts,
151151 round((sum(data_compressed_bytes) / sum(data_uncompressed_bytes)) * 100., 2) AS percentage
152152FROM system.parts WHERE active='1'
153153GROUP BY database, table
154- ORDER BY database, rows DESC
154+ ORDER BY rows DESC
155155LIMIT 50 FORMAT PrettyCompact"
156156echo
157157
158158echo " Top tables by size:"
159159clickhouse-client --query "
160- SELECT database, name, engine, is_temporary, metadata_modification_time, storage_policy, total_rows, round (sum(total_bytes) / 1024/1024/1024, 2) as size_gb
160+ SELECT database, name, engine, storage_policy, total_rows as rows, formatReadableSize (sum(total_bytes)) as size, is_temporary, metadata_modification_time
161161FROM system.tables
162- WHERE database != 'system'
162+ --WHERE database != 'system'
163+ WHERE total_rows > 0
163164GROUP BY database, name, engine, is_temporary, metadata_modification_time, storage_policy, total_rows, total_bytes
164- ORDER BY database, total_bytes DESC
165- LIMIT 10 FORMAT PrettyCompact"
165+ ORDER BY sum( total_bytes) DESC
166+ LIMIT 20 FORMAT PrettyCompact"
166167echo
167168
168- echo " Top tables MergeTree families by size :"
169+ echo " Parts of tables MergeTree families:"
169170clickhouse-client --query "
170- SELECT database, table, engine, disk_name, sum(rows) as rows, round(sum(bytes) / 1024/1024/1024, 2) as size_gb, countIf(active) data_parts_active, countIf(not active) data_parts_not_active
171+ SELECT database, table, engine, disk_name, countIf(active) data_parts_active, countIf(not active) data_parts_not_active
171172FROM system.parts
172- -- WHERE active
173173GROUP BY database, table, engine, disk_name
174- ORDER BY size_gb DESC
175- LIMIT 10 FORMAT PrettyCompact"
174+ ORDER BY database, table DESC
175+ LIMIT 20 FORMAT PrettyCompact"
176176echo
177177
178178echo " Tables in memory (Memory engine):"
@@ -189,7 +189,6 @@ clickhouse-client --query "SELECT * FROM system.detached_parts ORDER BY database
189189echo
190190
191191
192-
193192echo -e " ${CYANLIGHT} ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------${NC} "
194193
195194echo " Replicated tables located on the local server:"
@@ -252,6 +251,28 @@ SELECT user,
252251echo
253252
254253
254+ echo " Queries by memory consumption:"
255+ clickhouse-client --query "
256+ SELECT user,
257+ --client_hostname AS host,
258+ --client_name AS client,
259+ --formatDateTime(query_start_time, '%T') AS started,
260+ query_duration_ms / 1000 AS dur_sec,
261+ round(memory_usage / 1048576) AS mem_mb,
262+ result_rows,
263+ formatReadableSize(result_bytes) AS result_size,
264+ read_rows,
265+ formatReadableSize(read_bytes) AS read_size,
266+ written_rows as write_rows,
267+ formatReadableSize(written_bytes) AS write_size,
268+ query_id,
269+ substring(query,1,30) as query
270+ FROM system.query_log
271+ WHERE type = 2
272+ ORDER BY mem_mb DESC
273+ LIMIT 10 FORMAT PrettyCompact"
274+ echo
275+
255276
256277echo -e " ${CYANLIGHT} ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------${NC} "
257278
@@ -339,8 +360,8 @@ echo -e "${CYANLIGHT}-----------------------------------------------------------
339360
340361echo " Queries that is being processed. Ordered by elapsed time:"
341362echo " - full SQL text by query_id: SELECT distinct query FROM system.query_log WHERE query_id='' FORMAT TabSeparatedRaw"
342- echo " - kill: KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90 '"
343- echo " - kill: KILL QUERY WHERE user='username ' SYNC"
363+ echo " - kill by query_id : KILL QUERY WHERE query_id=''"
364+ echo " - kill all queries by user : KILL QUERY WHERE user='' SYNC"
344365clickhouse-client --query " SELECT elapsed as time_seconds, formatReadableSize(memory_usage) as memory, formatReadableSize(read_bytes) as read, read_rows, total_rows_approx as total_rows, user, address as client, query_id, substring(query,1,48) as query
345366FROM system.processes
346367ORDER BY elapsed desc FORMAT PrettyCompact"
0 commit comments