Skip to content

Instantly share code, notes, and snippets.

@inv2004
Last active September 9, 2019 04:13
Show Gist options
  • Save inv2004/474d1907e10867723557341d4e43be5d to your computer and use it in GitHub Desktop.
Save inv2004/474d1907e10867723557341d4e43be5d to your computer and use it in GitHub Desktop.
<test>
<!-- clickhouse performance-test --lite --input-file test.xml -->
<name>test</name>
<type>loop</type>
<stop_conditions>
<all_of>
<total_time_ms>30000</total_time_ms>
</all_of>
<any_of>
<average_speed_not_changing_for_ms>6000</average_speed_not_changing_for_ms>
<total_time_ms>60000</total_time_ms>
</any_of>
</stop_conditions>
<main_metric>
<queries_per_second />
<min_time />
</main_metric>
<substitutions>
<substitution>
<name>table_name</name>
<values>
<value>perf_test_orig</value>
<value>perf_test_new</value>
</values>
</substitution>
<substitution>
<name>rows</name>
<values>
<value>100000</value>
<value>1000000</value>
</values>
</substitution>
</substitutions>
<create_query>SET allow_experimental_data_skipping_indices = 1</create_query>
<create_query>
CREATE TABLE perf_test_orig (
c1 LowCardinality(String),
c2 UInt8,
c3 UInt16,
c4 UInt64,
timestamp_ns UInt64,
timestamp DateTime MATERIALIZED toDateTime(timestamp_ns / 1000000000),
c7 Enum8('A' = 0, 'B' = 1),
c8 Enum8('AA' = 0, 'BB' = 1),
c9 LowCardinality(String),
c10 String,
INDEX timestamp_idx timestamp TYPE minmax GRANULARITY 1,
INDEX c4_idx c4 TYPE minmax GRANULARITY 3
)
ENGINE = MergeTree()
ORDER BY (c1, c2, timestamp_ns)
PARTITION BY toYYYYMM(timestamp);
</create_query>
<create_query>
CREATE TABLE perf_test_new (
c1 LowCardinality(String),
c2 UInt8,
c3 UInt16,
c4 UInt64,
timestamp_ns UInt64,
timestamp DateTime MATERIALIZED toDateTime(timestamp_ns / 1000000000),
c7 Enum8('A' = 0, 'B' = 1),
c8 Enum8('AA' = 0, 'BB' = 1),
c9 LowCardinality(String),
c10 String
)
ENGINE = MergeTree()
ORDER BY (timestamp_ns, c1, c2)
PARTITION BY toYYYYMM(timestamp);
</create_query>
<create_query>SYSTEM STOP MERGES {table_name}</create_query>
<query>
SELECT COUNT() FROM (SELECT 'service_name_'||toString(rand() % 10), 0 == rand() % 10, 1, rand() % ({rows} / 30), (1546290000 * 10000 + number)*100000+rand()%1000000000 AS timestamp_ns, 'A', 0 == rand() % 2, '12345678901234'||toString(rand() % 10), '{"x":"'||toString(arrayResize([0], rand()%250))||'"}'
FROM system.numbers LIMIT {rows})
</query>
<query>
INSERT INTO {table_name} SELECT '1234567890123'||toString(rand() % 10), 0 == rand() % 10, 1, rand() % ({rows} / 30), (1546290000 * 10000 + number)*100000+rand()%1000000000 AS timestamp_ns, 'A', 0 == rand() % 2, '12345678901234'||toString(rand() % 10), '{"x":"'||toString(arrayResize([0], rand()%250))||'"}'
FROM system.numbers LIMIT {rows}
</query>
<drop_query>DROP TABLE IF EXISTS {table_name}</drop_query>
<drop_query>SYSTEM START MERGES {table_name}</drop_query>
</test>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment