ClickHouse/tests/queries/0_stateless/01780_column_sparse_pk.sql

35 lines
1.4 KiB
MySQL
Raw Normal View History

2021-04-14 13:20:05 +00:00
DROP TABLE IF EXISTS t_sparse_pk;
DROP TABLE IF EXISTS t_full_pk;
CREATE TABLE t_sparse_pk (k UInt64, s String)
ENGINE = MergeTree ORDER BY k
2021-05-19 01:48:46 +00:00
SETTINGS ratio_of_defaults_for_sparse_serialization = 0.0, index_granularity = 1;
2021-04-14 13:20:05 +00:00
INSERT INTO t_sparse_pk VALUES (0, 'a'), (0, 'b'), (1, ''), (2, ''), (2, 'e'), (3, 'f'), (4, 'g');
SET force_primary_key = 1;
SELECT k, s FROM t_sparse_pk WHERE k = 2 ORDER BY k, s;
SELECT k, s FROM t_sparse_pk WHERE k = 0 OR k = 3 ORDER BY k, s;
DROP TABLE IF EXISTS t_sparse_pk;
CREATE TABLE t_sparse_pk (k UInt64, v UInt64 CODEC(NONE))
ENGINE = MergeTree ORDER BY k
2021-05-19 01:48:46 +00:00
SETTINGS ratio_of_defaults_for_sparse_serialization = 0.0, index_granularity = 30;
2021-04-14 13:20:05 +00:00
CREATE TABLE t_full_pk (k UInt64, v UInt64)
ENGINE = MergeTree ORDER BY k
2021-05-19 01:48:46 +00:00
SETTINGS ratio_of_defaults_for_sparse_serialization = 1.1, index_granularity = 30;
2021-04-14 13:20:05 +00:00
INSERT INTO t_sparse_pk SELECT number % 10, number % 4 = 0 FROM numbers(1000);
INSERT INTO t_full_pk SELECT number % 10, number % 4 = 0 FROM numbers(1000);
INSERT INTO t_sparse_pk SELECT number % 10, number % 6 = 0 FROM numbers(1000);
INSERT INTO t_full_pk SELECT number % 10, number % 6 = 0 FROM numbers(1000);
SELECT count(v), sum(v) FROM t_sparse_pk WHERE k = 0;
SELECT count(v), sum(v) FROM t_full_pk WHERE k = 0;
SELECT count(v), sum(v) FROM t_sparse_pk WHERE k = 0 OR k = 3 OR k = 7 OR k = 8;
SELECT count(v), sum(v) FROM t_full_pk WHERE k = 0 OR k = 3 OR k = 7 OR k = 8;