ClickHouse/docs/en/sql-reference/statements/alter/statistic.md
2023-09-27 11:01:53 +02:00

1.2 KiB

slug sidebar_position sidebar_label
/en/sql-reference/statements/alter/statistic 45 STATISTIC

Manipulating Column Statistics

The following operations are available:

  • ALTER TABLE [db].table ADD STATISTIC (columns list) TYPE type - Adds statistic description to tables metadata.

  • ALTER TABLE [db].table DROP STATISTIC (columns list) TYPE type - Removes statistic description from tables metadata and deletes statistic files from disk.

  • ALTER TABLE [db].table CLEAR STATISTIC (columns list) TYPE type - Deletes statistic files from disk.

  • ALTER TABLE [db.]table MATERIALIZE STATISTIC (columns list) TYPE type - Rebuilds the statistic for columns. Implemented as a mutation.

The first two commands are lightweight in a sense that they only change metadata or remove files.

Also, they are replicated, syncing statistics metadata via ZooKeeper.

:::note
Statistic manipulation is supported only for tables with *MergeTree engine (including replicated variants). :::