ClickHouse/tests/performance/alter_select.xml
Azat Khuzhin a4f765cae7
Improve performance of SELECTs with active mutations (#59531)
* Configure keeper for perf tests

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

* Improve performance of SELECTs with active mutations

getAlterMutationCommandsForPart() can be a hot path for query execution
when there are pending mutations.

- LOG_TEST - it is not only check one bool, but actually a bunch of
  atomics as well.

- Return std::vector over std::map (map is not required there) - no
  changes in performance.

- Copy only RENAME_COLUMN (since only this mutation is required by
  AlterConversions).

And here are results:

run|result
-|-
SELECT w/o ALTER|queries: 1565, QPS: 355.259, RPS: 355.259
SELECT w/ ALTER unpatched|queries: 2099, QPS: 220.623, RPS: 220.623
SELECT w/ ALTER and w/o LOG_TEST|queries: 2730, QPS: 235.859, RPS: 235.859
SELECT w/ ALTER and w/o LOG_TEST and w/ RENAME_COLUMN only|queries: 2995, QPS: 290.982, RPS: 290.982

But there are still room for improvements, at least MergeTree engines
could implement getStorageSnapshotForQuery().

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

* Add AlterConversions::supportsMutationCommandType(), flatten vector<vector<MutationCommand>>

* Work around what appears to be a clang static analysis bug

---------

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
Co-authored-by: Michael Kolupaev <michael.kolupaev@clickhouse.com>
2024-02-22 08:51:10 +00:00

36 lines
1.4 KiB
XML

<test>
<substitutions>
<substitution>
<name>engine</name>
<values>
<value>mt</value>
<value>rmt</value>
</values>
</substitution>
</substitutions>
<create_query>create table alter_select_mt (part_id String, col_0 String) engine=MergeTree() partition by part_id order by tuple() settings max_parts_to_merge_at_once=1</create_query>
<create_query>create table alter_select_rmt (part_id String, col_0 String) engine=ReplicatedMergeTree('/tables/{{database}}', '{{table}}') partition by part_id order by tuple() settings max_parts_to_merge_at_once=1</create_query>
<create_query>system stop merges alter_select_{engine}</create_query>
<fill_query>
insert into alter_select_{engine} (part_id, col_0)
select toString(number % 5000), 0 from numbers(10000)
settings
max_block_size=1,
max_insert_threads=32,
min_insert_block_size_rows=1,
insert_deduplicate=false,
parts_to_delay_insert=100000,
parts_to_throw_insert=100000
</fill_query>
<fill_query>alter table alter_select_{engine} drop column col_0 settings alter_sync = 0</fill_query>
<query>select count() from alter_select_{engine} format Null settings max_threads=1</query>
<query>select * from alter_select_{engine} format Null settings max_threads=1</query>
<drop_query>drop table alter_select_{engine}</drop_query>
</test>