CLICKHOUSE — различия между версиями

Материал из megapuper
Перейти к: навигация, поиск
Строка 3: Строка 3:
 
  KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' - принудительно останавливает все запросы с указанным query_id
 
  KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' - принудительно останавливает все запросы с указанным query_id
  
 +
 +
select parts.*,
 +
        columns.compressed_size,
 +
        columns.uncompressed_size,
 +
        columns.ratio
 +
from (
 +
          select table,
 +
                formatReadableSize(sum(data_uncompressed_bytes))          AS uncompressed_size,
 +
                formatReadableSize(sum(data_compressed_bytes))            AS compressed_size,
 +
                sum(data_compressed_bytes) / sum(data_uncompressed_bytes) AS ratio
 +
          from system.columns
 +
          where database = currentDatabase()
 +
          group by table
 +
          ) columns
 +
          right join (
 +
    select table,
 +
            sum(rows)                                            as rows,
 +
            max(modification_time)                              as latest_modification,
 +
            formatReadableSize(sum(bytes))                      as disk_size,
 +
            formatReadableSize(sum(primary_key_bytes_in_memory)) as primary_keys_size,
 +
            any(engine)                                          as engine,
 +
            sum(bytes)                                          as bytes_size
 +
    from system.parts
 +
    where active and database = currentDatabase()
 +
    group by database, table
 +
    ) parts on columns.table = parts.table
 +
order by parts.bytes_size desc;
  
 
https://clickhouse.com/docs/ru/sql-reference/<br>
 
https://clickhouse.com/docs/ru/sql-reference/<br>
 
https://gist.github.com/sanchezzzhak/511fd140e8809857f8f1d84ddb937015
 
https://gist.github.com/sanchezzzhak/511fd140e8809857f8f1d84ddb937015

Версия 13:17, 3 февраля 2022

DESCRIBE TABLE stat - вывести описание столбцов таблицы
KILL QUERY WHERE query_id='2-857d-4a57-9ee0-327da5d60a90' - принудительно останавливает все запросы с указанным query_id


select parts.*,
       columns.compressed_size,
       columns.uncompressed_size,
       columns.ratio
from (
         select table,
                formatReadableSize(sum(data_uncompressed_bytes))          AS uncompressed_size,
                formatReadableSize(sum(data_compressed_bytes))            AS compressed_size,
                sum(data_compressed_bytes) / sum(data_uncompressed_bytes) AS ratio
         from system.columns
         where database = currentDatabase()
         group by table
         ) columns
         right join (
   select table,
           sum(rows)                                            as rows,
           max(modification_time)                               as latest_modification,
           formatReadableSize(sum(bytes))                       as disk_size,
           formatReadableSize(sum(primary_key_bytes_in_memory)) as primary_keys_size,
           any(engine)                                          as engine,
           sum(bytes)                                           as bytes_size
    from system.parts
    where active and database = currentDatabase()
    group by database, table
    ) parts on columns.table = parts.table
order by parts.bytes_size desc;

https://clickhouse.com/docs/ru/sql-reference/
https://gist.github.com/sanchezzzhak/511fd140e8809857f8f1d84ddb937015