upd 02241_join_rocksdb_bs.sql

This commit is contained in:
vdimir 2022-03-22 16:33:03 +00:00
parent 43afda408b
commit 54cf5c51de
No known key found for this signature in database
GPG Key ID: 6EE4CE2BEDC51862

View File

@ -3,11 +3,15 @@
SET join_algorithm = 'direct'; SET join_algorithm = 'direct';
{% for table_size in [10, 65555, 100000] -%} {% for table_size in [10, 65555, 100000] -%}
DROP TABLE IF EXISTS rdb_{{ table_size }};
{% endfor -%}
DROP TABLE IF EXISTS rdb; {% for table_size in [10, 65555, 100000] -%}
CREATE TABLE rdb (key UInt64, value String) ENGINE = EmbeddedRocksDB PRIMARY KEY (key); CREATE TABLE rdb_{{ table_size }} (key UInt64, value String) ENGINE = EmbeddedRocksDB PRIMARY KEY (key);
INSERT INTO rdb SELECT (sipHash64(number) % {{ table_size }}) as key, ('val' || toString(key)) as value FROM numbers_mt({{ table_size }}); INSERT INTO rdb_{{ table_size }}
SELECT (sipHash64(number) % {{ table_size }}) as key, ('val' || toString(key)) AS value
FROM numbers_mt({{ table_size }});
{% for block_size in [10, 11, 128, 129, 65505, 65506, 70000] -%} {% for block_size in [10, 11, 128, 129, 65505, 65506, 70000] -%}
@ -17,14 +21,14 @@ SET max_block_size = {{ block_size }};
{% for right_size in [table_size // 2, table_size + table_size // 4 + 1] -%} {% for right_size in [table_size // 2, table_size + table_size // 4 + 1] -%}
SELECT count() == (SELECT count() FROM rdb WHERE key < {{ right_size }}) SELECT count() == (SELECT count() FROM rdb_{{ table_size }} WHERE key < {{ right_size }})
FROM (SELECT number as k FROM numbers_mt({{ right_size }})) as t1 FROM (SELECT number as k FROM numbers_mt({{ right_size }})) as t1
INNER JOIN rdb INNER JOIN rdb_{{ table_size }} as rdb
ON rdb.key == t1.k; ON rdb.key == t1.k;
SELECT count() == {{ right_size }} and countIf(value != '') == (SELECT count() FROM rdb WHERE key < {{ right_size }}) SELECT count() == {{ right_size }} and countIf(value != '') == (SELECT count() FROM rdb_{{ table_size }} WHERE key < {{ right_size }})
FROM (SELECT number as k FROM numbers_mt({{ right_size }})) as t1 FROM (SELECT number as k FROM numbers_mt({{ right_size }})) as t1
LEFT JOIN rdb LEFT JOIN rdb_{{ table_size }} as rdb
ON rdb.key == t1.k; ON rdb.key == t1.k;
{% endfor -%} {% endfor -%}
@ -34,7 +38,7 @@ ON rdb.key == t1.k;
{% endfor -%} {% endfor -%}
{% endfor -%} {% endfor -%}
{% for table_size in [10, 65555, 100000] -%}
DROP TABLE rdb; DROP TABLE IF EXISTS rdb_{{ table_size }};
{% endfor -%}