Explore data from the terminal
ClickHouse comes with a very handy command line interface
clickhouse-client to explore data, debug queries, and more.
Here are some examples of using the ClickHouse CLI to interact with ClickHouse.
Explore data with readable formatting
You can run queries on the CLI, but the output formatting can be hard to read. You can use
FORMAT Vertical to make it easier to read.
SELECT * FROM table_with_a_lot_of_columns FORMAT Vertical
event_time: 2022-09-22 09:29:58
event_time_microseconds: 2022-09-22 09:29:58.298699
query_start_time: 2022-09-22 09:29:58
query_start_time_microseconds: 2022-09-22 09:29:58.296902
See query performance stats rather than query result
Queries you run in ClickHouse generate stats about the query performance. There are often multiple ways to write the same query, but each can have different performance characteristics. By analyzing the performance stats, it's possible to find the most optimised queries.
FORMAT Null to run the query and just print the query performance stats.
WHERE event_time > (now() - toIntervalMinute(10))
Query id: 7a125064-5422-471c-a170-e18601b2d631
0 rows in set. Elapsed: 0.019 sec. Processed 49.86 thousand rows, 1.81 MB (2.61 million rows/s., 94.45 MB/s.)