2017-12-11 12:07:26 +00:00
|
|
|
|
# Схема «Звезда»
|
2017-10-25 05:27:09 +00:00
|
|
|
|
|
|
|
|
|
Компилирование dbgen: <https://github.com/vadimtk/ssb-dbgen>
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
git clone git@github.com:vadimtk/ssb-dbgen.git
|
|
|
|
|
cd ssb-dbgen
|
|
|
|
|
make
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
В процессе будет некоторое количество предупреждений. Это нормально.
|
|
|
|
|
|
|
|
|
|
Разместите `dbgen` и `dists.dss` в какое-либо место с 800Гб свободного дискового пространства.
|
|
|
|
|
|
|
|
|
|
Генерация данных:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
./dbgen -s 1000 -T c
|
|
|
|
|
./dbgen -s 1000 -T l
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Создание таблиц в ClickHouse:
|
|
|
|
|
|
|
|
|
|
```sql
|
|
|
|
|
CREATE TABLE lineorder (
|
|
|
|
|
LO_ORDERKEY UInt32,
|
|
|
|
|
LO_LINENUMBER UInt8,
|
|
|
|
|
LO_CUSTKEY UInt32,
|
|
|
|
|
LO_PARTKEY UInt32,
|
|
|
|
|
LO_SUPPKEY UInt32,
|
|
|
|
|
LO_ORDERDATE Date,
|
|
|
|
|
LO_ORDERPRIORITY String,
|
|
|
|
|
LO_SHIPPRIORITY UInt8,
|
|
|
|
|
LO_QUANTITY UInt8,
|
|
|
|
|
LO_EXTENDEDPRICE UInt32,
|
|
|
|
|
LO_ORDTOTALPRICE UInt32,
|
|
|
|
|
LO_DISCOUNT UInt8,
|
|
|
|
|
LO_REVENUE UInt32,
|
|
|
|
|
LO_SUPPLYCOST UInt32,
|
|
|
|
|
LO_TAX UInt8,
|
|
|
|
|
LO_COMMITDATE Date,
|
|
|
|
|
LO_SHIPMODE String
|
|
|
|
|
)Engine=MergeTree(LO_ORDERDATE,(LO_ORDERKEY,LO_LINENUMBER,LO_ORDERDATE),8192);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE customer (
|
|
|
|
|
C_CUSTKEY UInt32,
|
|
|
|
|
C_NAME String,
|
|
|
|
|
C_ADDRESS String,
|
|
|
|
|
C_CITY String,
|
|
|
|
|
C_NATION String,
|
|
|
|
|
C_REGION String,
|
|
|
|
|
C_PHONE String,
|
|
|
|
|
C_MKTSEGMENT String,
|
|
|
|
|
C_FAKEDATE Date
|
|
|
|
|
)Engine=MergeTree(C_FAKEDATE,(C_CUSTKEY,C_FAKEDATE),8192);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE part (
|
|
|
|
|
P_PARTKEY UInt32,
|
|
|
|
|
P_NAME String,
|
|
|
|
|
P_MFGR String,
|
|
|
|
|
P_CATEGORY String,
|
|
|
|
|
P_BRAND String,
|
|
|
|
|
P_COLOR String,
|
|
|
|
|
P_TYPE String,
|
|
|
|
|
P_SIZE UInt8,
|
|
|
|
|
P_CONTAINER String,
|
|
|
|
|
P_FAKEDATE Date
|
|
|
|
|
)Engine=MergeTree(P_FAKEDATE,(P_PARTKEY,P_FAKEDATE),8192);
|
|
|
|
|
|
|
|
|
|
CREATE TABLE lineorderd AS lineorder ENGINE = Distributed(perftest_3shards_1replicas, default, lineorder, rand());
|
|
|
|
|
CREATE TABLE customerd AS customer ENGINE = Distributed(perftest_3shards_1replicas, default, customer, rand());
|
|
|
|
|
CREATE TABLE partd AS part ENGINE = Distributed(perftest_3shards_1replicas, default, part, rand());
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Для тестирования на одном сервере, используете просто таблицы типа MergeTree.
|
|
|
|
|
Для распределённого тестирования, нужно настроить кластер `perftest_3shards_1replicas` в конфигурационном файле.
|
|
|
|
|
Далее создать MergeTree таблицы на каждом сервере и Distributed таблицу поверх них.
|
|
|
|
|
|
|
|
|
|
Загрузка данных (нужно поменять customer на customerd в распределённом варианте):
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cat customer.tbl | sed 's/$/2000-01-01/' | clickhouse-client --query "INSERT INTO customer FORMAT CSV"
|
|
|
|
|
cat lineorder.tbl | clickhouse-client --query "INSERT INTO lineorder FORMAT CSV"
|
|
|
|
|
```
|