Skip to content

Instantly share code, notes, and snippets.

@den-crane
Last active August 17, 2022 20:12
Show Gist options
  • Save den-crane/801954ea154528e506596da9baa2f244 to your computer and use it in GitHub Desktop.
Save den-crane/801954ea154528e506596da9baa2f244 to your computer and use it in GitHub Desktop.
async_insert.txt
<?xml version="1.0" ?>
<clickhouse>
<profiles>
<default>
<async_insert>true</async_insert>
<wait_for_async_insert>0</wait_for_async_insert>
<async_insert_threads>32</async_insert_threads>
<async_insert_max_data_size>20000000</async_insert_max_data_size>
<async_insert_busy_timeout_ms>30000</async_insert_busy_timeout_ms>
</default>
</profiles>
</clickhouse>
create table test(a Int64) Engine = MergeTree order by a;
(for i in `seq 500`; do echo 'INSERT INTO test VALUES (1),(2),(3)' | curl 'http://localhost:8123/' --data-binary @-; sleep .5; done;) &
(for i in `seq 500`; do echo 'INSERT INTO test VALUES (1),(2),(3)' | curl 'http://localhost:8123/' --data-binary @-; sleep .2; done;) &
(for i in `seq 5000`; do echo 'INSERT INTO test VALUES (1),(2),(3)' | curl 'http://localhost:8123/' --data-binary @-; sleep .1; done;) &
(for i in `seq 5000`; do echo 'INSERT INTO test VALUES (1),(2),(3""")' | curl 'http://localhost:8123/' --data-binary @-; sleep .1; done;) &
tail -f /var/log/clickhouse-server/clickhouse-server.log|grep Flushed
2022.08.17 13:52:18.661663 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 180 rows, 1440 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:52:49.011815 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 180 rows, 1440 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:53:19.368062 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 180 rows, 1440 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:53:49.714167 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 378 rows, 3024 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:54:19.723372 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 651 rows, 5208 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:54:49.857515 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 654 rows, 5232 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:55:19.868565 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 564 rows, 4512 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:55:49.940750 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 492 rows, 3936 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:56:19.976896 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 408 rows, 3264 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:56:50.351946 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 180 rows, 1440 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:57:20.703084 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 180 rows, 1440 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:57:51.060786 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 429 rows, 3432 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:58:21.083762 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 1470 rows, 11760 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:58:51.149427 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 2286 rows, 18288 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:59:21.161816 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 2940 rows, 23520 bytes for query 'INSERT INTO default.test FORMAT Values'
2022.08.17 13:59:51.221362 [ 27262 ] {} <Information> AsynchronousInsertQueue: Flushed 2631 rows, 21048 bytes for query 'INSERT INTO default.test FORMAT Values'
clickhouse-client -q 'select * from numbers(10) format RowBinary' > async.r
for i in `seq 150`; do echo "create table test$i(a Int64) Engine = MergeTree order by a;"| curl 'http://localhost:8123/' --data-binary @-; done;
(for i in `seq 500`; do curl 'http://localhost:8123/?query=INSERT+INTO+test+format+RowBinary' --data-binary @async.r; sleep .5; done;) &
(for i in `seq 500`; do curl 'http://localhost:8123/?query=INSERT+INTO+test+format+RowBinary' --data-binary @async.r; sleep .2; done;) &
(for i in `seq 150`; do curl "http://localhost:8123/?query=INSERT+INTO+test$i+format+RowBinary" --data-binary @async.r; sleep 2; done;) &
(for i in `seq 150`; do curl "http://localhost:8123/?query=INSERT+INTO+test$i+format+RowBinary" --data-binary @async.r; sleep 2; done;) &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment