2021-04-23 14:32:56 +00:00
#!/usr/bin/env bash
CURDIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
# shellcheck source=../shell_config.sh
. " $CURDIR " /../shell_config.sh
2023-02-21 21:32:55 +00:00
$CLICKHOUSE_CLIENT -q "CREATE TABLE test_sort_proj (x UInt32, y UInt32, PROJECTION p (SELECT x, y ORDER BY y)) ENGINE = MergeTree ORDER BY x SETTINGS index_granularity=8192, index_granularity_bytes='10Mi'"
2021-05-03 16:41:48 +00:00
$CLICKHOUSE_CLIENT -q "insert into test_sort_proj select number, toUInt32(-number - 1) from numbers(100)"
2021-04-23 14:32:56 +00:00
echo "select where x < 10"
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 0, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE x < 10 order by x
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 0, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 0, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE x < 10 order by x
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 0, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 1, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE x < 10 order by x
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 1, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 1, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE x < 10 order by x
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 1, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 0, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE x < 10 order by x FORMAT JSON
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 0, optimize_use_projections = 0" | grep rows_read
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 0, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE x < 10 order by x FORMAT JSON
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 0, optimize_use_projections = 1" | grep rows_read
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 1, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE x < 10 order by x FORMAT JSON
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 1, optimize_use_projections = 0" | grep rows_read
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 1, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE x < 10 order by x FORMAT JSON
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 1, optimize_use_projections = 1" | grep rows_read
2021-04-23 14:32:56 +00:00
echo "select where y > 4294967286"
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 0, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 0, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 0, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 0, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 1, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 1, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 1, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 1, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 0, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x FORMAT JSON
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 0, optimize_use_projections = 0" | grep rows_read
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 0, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x FORMAT JSON
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 0, optimize_use_projections = 1" | grep rows_read
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 1, optimize_use_projections = 0"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x FORMAT JSON
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 1, optimize_use_projections = 0" | grep rows_read
2021-04-23 14:32:56 +00:00
2023-05-10 01:35:13 +00:00
echo "optimize_move_to_prewhere = 1, optimize_use_projections = 1"
2021-04-23 14:32:56 +00:00
$CLICKHOUSE_CLIENT -q " SELECT * FROM test_sort_proj WHERE y > 4294967286 order by x FORMAT JSON
2023-05-10 01:35:13 +00:00
SETTINGS optimize_move_to_prewhere = 1, optimize_use_projections = 1" | grep rows_read
2021-04-23 14:32:56 +00:00
2021-09-16 21:19:58 +00:00
$CLICKHOUSE_CLIENT -q "ALTER TABLE test_sort_proj DELETE WHERE x % 2 = 0 SETTINGS mutations_sync=2;"
$CLICKHOUSE_CLIENT -q "SELECT count() from test_sort_proj;"
2021-06-07 17:29:19 +00:00
$CLICKHOUSE_CLIENT -q "DROP TABLE test_sort_proj"