How to create primary keys in ClickHouse

I found several examples in the documentation where primary keys are created by passing parameters to the ENGINE section. But I did not find a description of any arguments for ENGINE, what it means and how to create a primary key. Thanks in advance. It would be great to add this information to documentation that it does not represent.

+4
source share
1 answer

Primary key is supported for MergeTree storage engine families. https://clickhouse.yandex/reference_en.html#MergeTree

Please note that for most serious tasks you should use the MergeTree Family.

.

: , , (), , , .

:

MergeTree(EventDate, (CounterID, EventDate), 8192)

:

MergeTree(EventDate, intHash32(UserID), (CounterID, EventDate, intHash32(UserID)), 8192)

, (CounterID, EventDate) (CounterID, EventDate, intHash32(UserID)) .

ReplicatedMergeTree , .

https://clickhouse.yandex/reference_en.html#Creating%20replicated%20tables

.

, . . .

+5

Source: https://habr.com/ru/post/1649687/


All Articles