ClickHouse/tests/performance/ip_trie.xml

90 lines
2.5 KiB
XML
Raw Normal View History

<test>
<create_query>
CREATE TABLE table_ip_trie
(
ip String,
ver UInt8,
val Float32
) ENGINE = TinyLog
</create_query>
<create_query>
INSERT INTO table_ip_trie
SELECT
IPv4NumToString(ipv4) || '/' || toString(rand() % 17 + 16) as ip,
4 as ver,
val
FROM generateRandom('ipv4 UInt32, val Float32', 0, 30, 30)
2020-11-16 18:08:31 +00:00
LIMIT 200000
</create_query>
<create_query>
INSERT INTO table_ip_trie
SELECT
IPv6NumToString(ipv6) || '/' || toString(rand() % 65 + 64) as ip,
6 as ver,
val
FROM generateRandom('ipv6 FixedString(16), val Float32', 0, 30, 30)
2020-11-12 18:47:10 +00:00
LIMIT 2500000
</create_query>
<create_query>
CREATE DICTIONARY dict_ip_trie
(
ip String,
ver UInt8,
val Float32
)
PRIMARY KEY ip
2020-11-12 18:47:10 +00:00
SOURCE(CLICKHOUSE(DB 'default' TABLE 'table_ip_trie'))
LAYOUT(IP_TRIE())
LIFETIME(300)
</create_query>
2020-11-12 18:47:10 +00:00
<create_query>
CREATE TABLE dict_ip_trie_table
(
2020-11-12 18:47:10 +00:00
`ip` String,
`ver` UInt8,
`val` Float32
) ENGINE = Dictionary(default.dict_ip_trie)
2020-11-12 18:47:10 +00:00
</create_query>
<create_query>
CREATE TABLE table_ip_from_dict (`ip` String, `ver` UInt8) ENGINE = TinyLog
</create_query>
<create_query>
INSERT INTO table_ip_from_dict
2020-11-16 18:08:31 +00:00
SELECT splitByChar('/', ip )[1] as ip, ver FROM dict_ip_trie_table
</create_query>
<query>
2020-11-12 18:47:10 +00:00
SELECT dictGetFloat32('default.dict_ip_trie', 'val', tuple(rand32()))
FROM numbers(500000) FORMAT Null
</query>
<query>
2020-11-12 18:47:10 +00:00
SELECT dictGetFloat32('default.dict_ip_trie', 'val', tuple(randomFixedString(16)))
FROM numbers(500000) FORMAT Null
</query>
<query>
2020-11-16 18:08:31 +00:00
SELECT dictGetFloat32('default.dict_ip_trie', 'val', tuple(IPv6StringToNum(ip)))
FROM table_ip_from_dict
WHERE ver == 4
LIMIT 500000 FORMAT Null
</query>
<query>
SELECT dictGetFloat32('default.dict_ip_trie', 'val', tuple(IPv6StringToNum(ip)))
FROM table_ip_from_dict
WHERE ver == 6
LIMIT 500000 FORMAT Null
</query>
2021-11-03 15:06:19 +00:00
<drop_query>DROP TABLE IF EXISTS table_ip_from_dict</drop_query>
<drop_query>DROP TABLE IF EXISTS dict_ip_trie_table</drop_query>
<drop_query>DROP DICTIONARY IF EXISTS default.dict_ip_trie</drop_query>
<drop_query>DROP TABLE IF EXISTS table_ip_trie</drop_query>
</test>