2020-03-11 16:47:17 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
2020-12-28 11:46:53 +00:00
|
|
|
# shellcheck source=../shell_config.sh
|
2020-08-01 00:51:12 +00:00
|
|
|
. "$CURDIR"/../shell_config.sh
|
2020-03-11 16:47:17 +00:00
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS mt_compact"
|
|
|
|
|
|
|
|
# Checks that granularity correctly computed from small parts.
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT -q "CREATE TABLE mt_compact(a Int, s String) ENGINE = MergeTree ORDER BY a
|
|
|
|
SETTINGS min_rows_for_wide_part = 1000,
|
|
|
|
index_granularity = 14;"
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT -q "SYSTEM STOP MERGES mt_compact"
|
|
|
|
|
|
|
|
$CLICKHOUSE_CLIENT --max_block_size=1 --min_insert_block_size_rows=1 -q \
|
|
|
|
"INSERT INTO mt_compact SELECT number, 'aaa' FROM numbers(100);"
|
|
|
|
|
2020-12-04 02:15:44 +00:00
|
|
|
$CLICKHOUSE_CLIENT -q "SELECT count() FROM system.parts WHERE table = 'mt_compact' AND database = '$CLICKHOUSE_DATABASE' AND active"
|
2020-03-11 16:47:17 +00:00
|
|
|
$CLICKHOUSE_CLIENT -q "SYSTEM START MERGES mt_compact"
|
|
|
|
|
|
|
|
# Retry because already started concurrent merges may interrupt optimize
|
2020-08-01 00:40:56 +00:00
|
|
|
for _ in {0..10}; do
|
2020-03-11 16:47:17 +00:00
|
|
|
$CLICKHOUSE_CLIENT -q "OPTIMIZE TABLE mt_compact FINAL SETTINGS optimize_throw_if_noop=1" 2>/dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
break
|
|
|
|
fi
|
2020-03-11 18:43:46 +00:00
|
|
|
sleep 0.1
|
2020-03-11 16:47:17 +00:00
|
|
|
done
|
|
|
|
|
2020-12-04 02:15:44 +00:00
|
|
|
$CLICKHOUSE_CLIENT -q "SELECT count(), sum(marks) FROM system.parts WHERE table = 'mt_compact' AND database = '$CLICKHOUSE_DATABASE' AND active"
|
2020-03-11 16:47:17 +00:00
|
|
|
$CLICKHOUSE_CLIENT -q "DROP TABLE mt_compact"
|