update function test

This commit is contained in:
王智博 2023-08-21 17:47:55 +08:00
parent 8bb0f18019
commit 0e2b815960
4 changed files with 103 additions and 105 deletions

View File

@ -1,83 +1,83 @@
ReadFromMergeTree (default.test_index)
Indexes:
MinMax
Keys:
y
Condition: (y in [1, +Inf))
Parts: 4/5
Granules: 11/12
Partition
Keys:
y
bitAnd(z, 3)
Condition: and((y in [1, +Inf)), (bitAnd(z, 3) not in [1, 1]))
Parts: 3/4
Granules: 10/11
PrimaryKey
Keys:
x
y
Condition: and((x in [11, +Inf)), (y in [1, +Inf)))
Parts: 2/3
Granules: 6/10
Skip
Name: t_minmax
Description: minmax GRANULARITY 2
Parts: 1/2
Granules: 4/6
Skip
Name: t_set
Description: set GRANULARITY 2
Parts: 1/1
Granules: 2/4
ReadFromMergeTree (default.test_index)
Indexes:
MinMax
Keys:
y
Condition: (y in [1, +Inf))
Parts: 4/5
Granules: 11/12
Partition
Keys:
y
bitAnd(z, 3)
Condition: and((y in [1, +Inf)), (bitAnd(z, 3) not in [1, 1]))
Parts: 3/4
Granules: 10/11
PrimaryKey
Keys:
x
y
Condition: and((x in [11, +Inf)), (y in [1, +Inf)))
Parts: 2/3
Granules: 6/10
Skip
Name: t_minmax
Description: minmax GRANULARITY 2
Parts: 1/2
Granules: 3/6
Skip
Name: t_set
Description: set GRANULARITY 2
Parts: 1/1
Granules: 2/3
-----------------
"Node Type": "ReadFromMergeTree",
"Description": "default.test_index",
"Indexes": [
{
"Type": "MinMax",
"Keys": ["y"],
"Condition": "(y in [1, +Inf))",
"Initial Parts": 5,
"Selected Parts": 4,
"Initial Granules": 12,
"Selected Granules": 11
},
{
"Type": "Partition",
"Keys": ["y", "bitAnd(z, 3)"],
"Condition": "and((y in [1, +Inf)), (bitAnd(z, 3) not in [1, 1]))",
"Initial Parts": 4,
"Selected Parts": 3,
"Initial Granules": 11,
"Selected Granules": 10
},
{
"Type": "PrimaryKey",
"Keys": ["x", "y"],
"Condition": "and((x in [11, +Inf)), (y in [1, +Inf)))",
"Initial Parts": 3,
"Selected Parts": 2,
"Initial Granules": 10,
"Selected Granules": 6
},
{
"Type": "Skip",
"Name": "t_minmax",
"Description": "minmax GRANULARITY 2",
"Initial Parts": 2,
"Selected Parts": 1,
"Initial Granules": 6,
"Selected Granules": 4
},
{
"Type": "Skip",
"Name": "t_set",
"Description": "set GRANULARITY 2",
"Initial Parts": 1,
"Selected Parts": 1,
"Initial Granules": 4,
"Selected Granules": 2
"Node Type": "ReadFromMergeTree",
"Description": "default.test_index",
"Indexes": [
{
"Type": "MinMax",
"Keys": ["y"],
"Condition": "(y in [1, +Inf))",
"Initial Parts": 5,
"Selected Parts": 4,
"Initial Granules": 12,
"Selected Granules": 11
},
{
"Type": "Partition",
"Keys": ["y", "bitAnd(z, 3)"],
"Condition": "and((y in [1, +Inf)), (bitAnd(z, 3) not in [1, 1]))",
"Initial Parts": 4,
"Selected Parts": 3,
"Initial Granules": 11,
"Selected Granules": 10
},
{
"Type": "PrimaryKey",
"Keys": ["x", "y"],
"Condition": "and((x in [11, +Inf)), (y in [1, +Inf)))",
"Initial Parts": 3,
"Selected Parts": 2,
"Initial Granules": 10,
"Selected Granules": 6
},
{
"Type": "Skip",
"Name": "t_minmax",
"Description": "minmax GRANULARITY 2",
"Initial Parts": 2,
"Selected Parts": 1,
"Initial Granules": 6,
"Selected Granules": 3
},
{
"Type": "Skip",
"Name": "t_set",
"Description": "set GRANULARITY 2",
"Initial Parts": 1,
"Selected Parts": 1,
"Initial Granules": 3,
"Selected Granules": 2
}
]
}

View File

@ -1,21 +0,0 @@
DROP TABLE IF EXISTS test_skip_idx;
CREATE TABLE test_skip_idx
(
`id` UInt32,
INDEX name_idx_g2 id TYPE minmax GRANULARITY 2,
INDEX name_idx_g1 id TYPE minmax GRANULARITY 1
)
ENGINE = MergeTree
ORDER BY tuple()
SETTINGS index_granularity = 1, index_granularity_bytes = 0;
INSERT INTO test_skip_idx SELECT number FROM system.numbers LIMIT 5 OFFSET 1;
EXPLAIN indexes = 1 SELECT * FROM test_skip_idx WHERE id < 2;
SELECT '--';
EXPLAIN indexes = 1 SELECT * FROM test_skip_idx WHERE id < 3;
DROP TABLE IF EXISTS test_skip_idx;

View File

@ -1,5 +1,3 @@
Expression ((Projection + Before ORDER BY))
Filter (WHERE)
ReadFromMergeTree (default.test_skip_idx)
Indexes:
Skip
@ -12,9 +10,7 @@ Expression ((Projection + Before ORDER BY))
Description: minmax GRANULARITY 1
Parts: 1/1
Granules: 1/2
--
Expression ((Projection + Before ORDER BY))
Filter (WHERE)
-----------------
ReadFromMergeTree (default.test_skip_idx)
Indexes:
Skip

View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Tags: no-random-merge-tree-settings
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
CLICKHOUSE_CLIENT="$CLICKHOUSE_CLIENT --optimize_move_to_prewhere=1 --convert_query_to_cnf=0 --optimize_read_in_order=1"
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS test_skip_idx"
$CLICKHOUSE_CLIENT -q "CREATE TABLE test_skip_idx (id UInt32, INDEX name_idx_g2 id TYPE minmax GRANULARITY 2, INDEX name_idx_g1 id TYPE minmax GRANULARITY 1) ENGINE = MergeTree ORDER BY tuple() SETTINGS index_granularity = 1, index_granularity_bytes = 0"
$CLICKHOUSE_CLIENT -q "INSERT INTO test_skip_idx SELECT number FROM system.numbers LIMIT 5 OFFSET 1"
$CLICKHOUSE_CLIENT -q "
EXPLAIN indexes = 1 SELECT * FROM test_skip_idx WHERE id < 2
" | grep -A 100 "ReadFromMergeTree" # | grep -v "Description"
echo "-----------------"
$CLICKHOUSE_CLIENT -q "
EXPLAIN indexes = 1 SELECT * FROM test_skip_idx WHERE id < 3
" | grep -A 100 "ReadFromMergeTree" # | grep -v "Description"