Skip to content

Instantly share code, notes, and snippets.

@maxjustus
Last active May 24, 2024 17:25
Show Gist options
  • Save maxjustus/03d2c3ad73f9ec4fe80cdb25bf93a058 to your computer and use it in GitHub Desktop.
Save maxjustus/03d2c3ad73f9ec4fe80cdb25bf93a058 to your computer and use it in GitHub Desktop.
clickhouse client examples
# The clickhouse client --format flag specifies the output format of query results that
# get printed to the console by clickhouse client. There are a many options. See: https://clickhouse.com/docs/en/interfaces/formats
# The Null format will not print any query results for the console, which in this case is useful because we are only
# interested in analyzing the trace logs that are printed to the console and any query output just adds noise.
# inline query example:
clickhouse client --send-logs-level="trace" --database=test --progress --query="select* from system.numbers limit 10;" --format=Null
# Multi statement query file example:
echo "
create or replace table a engine=MergeTree order by number as select number from system.numbers limit 1000;
create or replace table b engine=MergeTree order by number as select number from system.numbers limit 1000;
select * from a join b on a.number = b.number;
" > my_query.sql
clickhouse client --send-logs-level="trace" --database=test --progress --multiquery --queries-file=my_query.sql --format=Null
# writing trace output to a file:
clickhouse client --send-logs-level="trace" --database=test --progress --multiquery --queries-file=my_query.sql --format=Null 2> my_query_trace_log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment