Skip to content

Instantly share code, notes, and snippets.

@den-crane
Last active January 21, 2020 23:07
Show Gist options
  • Save den-crane/bc35a15a8d71899fe15e5ed36668d387 to your computer and use it in GitHub Desktop.
Save den-crane/bc35a15a8d71899fe15e5ed36668d387 to your computer and use it in GitHub Desktop.
MV wrong deduplication
CREATE TABLE test12345 (A Int64)
ENGINE = ReplicatedMergeTree ('/clickhouse/{cluster}/tables/test','{replica}')
ORDER BY tuple();
CREATE MATERIALIZED VIEW test12345mv Engine=ReplicatedMergeTree ('/clickhouse/{cluster}/tables/test12345mv','{replica}')
partition by A order by tuple()
AS SELECT A FROM test12345;
SET max_partitions_per_insert_block = 3;
insert into test12345 select number from numbers(10);
DB::Exception: Received from localhost:9000. DB::Exception: Too many partitions for single INSERT block (more than 3).
SELECT count() FROM test12345
┌─count()─┐
│ 10 │
└─────────┘
1 rows in set. Elapsed: 0.001 sec.
SELECT count() FROM test12345mv
Ok.
0 rows in set. Elapsed: 0.001 sec.
------
убираем проблему, делаем ретрай, инсерт в таблицу дедуплицируется, MV остается пустым
SET max_partitions_per_insert_block = 1000;
INSERT INTO test12345 SELECT number FROM numbers(10)
Ok.
0 rows in set. Elapsed: 0.008 sec.
SELECT count() FROM test12345
┌─count()─┐
│ 10 │
└─────────┘
1 rows in set. Elapsed: 0.001 sec.
SELECT count() FROM test12345mv
Ok.
0 rows in set. Elapsed: 0.001 sec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment