tests/performance: cover sparse_hashed dictionary (#40027)

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
Azat Khuzhin 2022-08-10 21:48:00 +02:00 committed by GitHub
parent 9f85d85e08
commit 6a30c23252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,72 +1,4 @@
<test> <test>
<create_query>
CREATE TABLE simple_key_hashed_dictionary_source_table
(
id UInt64,
value_int UInt64,
value_string String,
value_decimal Decimal64(8),
value_string_nullable Nullable(String)
) ENGINE = Memory;
</create_query>
<create_query>
CREATE TABLE complex_key_hashed_dictionary_source_table
(
id UInt64,
id_key String,
value_int UInt64,
value_string String,
value_decimal Decimal64(8),
value_string_nullable Nullable(String)
) ENGINE = Memory;
</create_query>
<create_query>
CREATE DICTIONARY simple_key_hashed_dictionary
(
id UInt64,
value_int UInt64,
value_string String,
value_decimal Decimal64(8),
value_string_nullable Nullable(String)
)
PRIMARY KEY id
SOURCE(CLICKHOUSE(DB 'default' TABLE 'simple_key_hashed_dictionary_source_table'))
LAYOUT(HASHED())
LIFETIME(MIN 0 MAX 1000);
</create_query>
<create_query>
CREATE DICTIONARY complex_key_hashed_dictionary
(
id UInt64,
id_key String,
value_int UInt64,
value_string String,
value_decimal Decimal64(8),
value_string_nullable Nullable(String)
)
PRIMARY KEY id, id_key
SOURCE(CLICKHOUSE(DB 'default' TABLE 'complex_key_hashed_dictionary_source_table'))
LAYOUT(COMPLEX_KEY_HASHED())
LIFETIME(MIN 0 MAX 1000);
</create_query>
<fill_query>
INSERT INTO simple_key_hashed_dictionary_source_table
SELECT number, number, toString(number), toDecimal64(number, 8), toString(number)
FROM system.numbers
LIMIT 5000000;
</fill_query>
<fill_query>
INSERT INTO complex_key_hashed_dictionary_source_table
SELECT number, toString(number), number, toString(number), toDecimal64(number, 8), toString(number)
FROM system.numbers
LIMIT 5000000;
</fill_query>
<substitutions> <substitutions>
<substitution> <substitution>
<name>column_name</name> <name>column_name</name>
@ -85,54 +17,129 @@
<value>7500000</value> <value>7500000</value>
</values> </values>
</substitution> </substitution>
<substitution>
<name>layout_suffix</name>
<values>
<value>HASHED</value>
<value>SPARSE_HASHED</value>
</values>
</substitution>
</substitutions> </substitutions>
<create_query>
CREATE TABLE simple_key_dictionary_source_table
(
id UInt64,
value_int UInt64,
value_string String,
value_decimal Decimal64(8),
value_string_nullable Nullable(String)
) ENGINE = Memory
</create_query>
<create_query>
CREATE TABLE complex_key_dictionary_source_table
(
id UInt64,
id_key String,
value_int UInt64,
value_string String,
value_decimal Decimal64(8),
value_string_nullable Nullable(String)
) ENGINE = Memory
</create_query>
<create_query>
CREATE DICTIONARY IF NOT EXISTS simple_key_{layout_suffix}_dictionary
(
id UInt64,
value_int UInt64,
value_string String,
value_decimal Decimal64(8),
value_string_nullable Nullable(String)
)
PRIMARY KEY id
SOURCE(CLICKHOUSE(TABLE 'simple_key_dictionary_source_table'))
LAYOUT({layout_suffix}())
LIFETIME(0)
</create_query>
<create_query>
CREATE DICTIONARY IF NOT EXISTS complex_key_{layout_suffix}_dictionary
(
id UInt64,
id_key String,
value_int UInt64,
value_string String,
value_decimal Decimal64(8),
value_string_nullable Nullable(String)
)
PRIMARY KEY id, id_key
SOURCE(CLICKHOUSE(TABLE 'complex_key_dictionary_source_table'))
LAYOUT(COMPLEX_KEY_{layout_suffix}())
LIFETIME(0)
</create_query>
<fill_query>
INSERT INTO simple_key_dictionary_source_table
SELECT number, number, toString(number), toDecimal64(number, 8), toString(number)
FROM system.numbers
LIMIT 5000000
</fill_query>
<fill_query>
INSERT INTO complex_key_dictionary_source_table
SELECT number, toString(number), number, toString(number), toDecimal64(number, 8), toString(number)
FROM system.numbers
LIMIT 5000000
</fill_query>
<fill_query>SYSTEM RELOAD DICTIONARY simple_key_{layout_suffix}_dictionary</fill_query>
<fill_query>SYSTEM RELOAD DICTIONARY complex_key_{layout_suffix}_dictionary</fill_query>
<query>SYSTEM RELOAD DICTIONARY simple_key_{layout_suffix}_dictionary</query>
<query>SYSTEM RELOAD DICTIONARY complex_key_{layout_suffix}_dictionary</query>
<query> <query>
WITH rand64() % toUInt64({elements_count}) as key WITH rand64() % toUInt64({elements_count}) as key
SELECT dictGet('default.simple_key_hashed_dictionary', {column_name}, key) SELECT dictGet('default.simple_key_{layout_suffix}_dictionary', {column_name}, key)
FROM system.numbers FROM system.numbers
LIMIT {elements_count} LIMIT {elements_count}
FORMAT Null; FORMAT Null
</query> </query>
<query> <query>
WITH rand64() % toUInt64({elements_count}) as key WITH rand64() % toUInt64({elements_count}) as key
SELECT dictHas('default.simple_key_hashed_dictionary', key) SELECT dictHas('default.simple_key_{layout_suffix}_dictionary', key)
FROM system.numbers FROM system.numbers
LIMIT {elements_count} LIMIT {elements_count}
FORMAT Null; FORMAT Null
</query> </query>
<query>SELECT * FROM simple_key_{layout_suffix}_dictionary FORMAT Null</query>
<query> <query>
SELECT * FROM simple_key_hashed_dictionary WITH (rand64() % toUInt64({elements_count}), toString(rand64() % toUInt64({elements_count}))) as key
FORMAT Null; SELECT dictGet('default.complex_key_{layout_suffix}_dictionary', {column_name}, key)
FROM system.numbers
LIMIT {elements_count}
FORMAT Null
</query> </query>
<query> <query>
WITH (rand64() % toUInt64({elements_count}), toString(rand64() % toUInt64({elements_count}))) as key WITH (rand64() % toUInt64({elements_count}), toString(rand64() % toUInt64({elements_count}))) as key
SELECT dictGet('default.complex_key_hashed_dictionary', {column_name}, key) SELECT dictHas('default.complex_key_{layout_suffix}_dictionary', key)
FROM system.numbers FROM system.numbers
LIMIT {elements_count} LIMIT {elements_count}
FORMAT Null; FORMAT Null
</query> </query>
<query> <query>SELECT * FROM complex_key_{layout_suffix}_dictionary FORMAT Null</query>
WITH (rand64() % toUInt64({elements_count}), toString(rand64() % toUInt64({elements_count}))) as key
SELECT dictHas('default.complex_key_hashed_dictionary', key)
FROM system.numbers
LIMIT {elements_count}
FORMAT Null;
</query>
<query> <drop_query>DROP TABLE IF EXISTS simple_key_dictionary_source_table</drop_query>
SELECT * FROM complex_key_hashed_dictionary <drop_query>DROP TABLE IF EXISTS complex_key_dictionary_source_table</drop_query>
FORMAT Null;
</query>
<drop_query>DROP TABLE IF EXISTS simple_key_hashed_dictionary_source_table;</drop_query>
<drop_query>DROP TABLE IF EXISTS complex_key_hashed_dictionary_source_table;</drop_query>
<drop_query>DROP DICTIONARY IF EXISTS simple_key_hashed_dictionary;</drop_query>
<drop_query>DROP DICTIONARY IF EXISTS complex_key_hashed_dictionary;</drop_query>
<drop_query>DROP DICTIONARY IF EXISTS simple_key_{layout_suffix}_dictionary</drop_query>
<drop_query>DROP DICTIONARY IF EXISTS complex_key_{layout_suffix}_dictionary</drop_query>
</test> </test>