User Tools

Site Tools


software:clickhouse

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

software:clickhouse [2021/08/02 14:29] (current)
rb created
Line 1: Line 1:
 +====== Хелперы работы с clickhouse ======
 +
 +<code>
 +SELECT partition, name, table FROM system.parts WHERE active
 +
 +</code>
 +
 +ss
 +
 +<code>
 +SELECT * FROM system.parts WHERE active limit 1
 +
 +</code>
 +
 +ss
 +
 +<code>
 +SELECT
 +    name,
 +    type,
 +    formatReadableSize(data_compressed_bytes) AS compressed,
 +    formatReadableSize(data_uncompressed_bytes) AS uncompressed,
 +    data_uncompressed_bytes / data_compressed_bytes AS ratio,
 +    compression_codec
 +FROM system.columns
 +WHERE (database = 'traffic') AND (table = 'raw')
 +ORDER BY data_compressed_bytes DESC
 +
 +</code>
 +===== Изменение алгоритма компресии для колонки =====
 +
 +<code>
 +ALTER TABLE <database>.<table> MODIFY COLUMN <column> CODEC(Delta(4), ZSTD(10))
 +
 +</code>
 +
 +Changes are applied lazily: only for new data and while merging. A trick to rewrite column data on disk:
 +
 +<code>
 +ALTER TABLE <database>.<table> UPDATE <column> = <column> WHERE 1
 +
 +</code>
 +
 +Процедура выполняется в фоне, чтобы проверить статус:
 +
 +<code>
 +select * from system.mutations
 +
 +</code>
 +
  
software/clickhouse.txt · Last modified: 2021/08/02 14:29 by rb