Query Managed ClickHouse® databases
Run a query against a Managed ClickHouse® database using a tool of your choice.
To ensure data security, stability, and its proper replication, we equip
our Managed ClickHouse® service with specific features, some
of them missing from the standard ClickHouse offer. Managed ClickHouse takes care of running queries in the distributed mode over
the entire cluster. In the standard ClickHouse, the queries CREATE,
ALTER, RENAME and DROP only affect the server where they are run.
In contrast, we ensure the proper distribution across all cluster
machines behind the scenes. You don’t need to use ON CLUSTER for data
definition queries against a Replicated database.
Important
There are limitations on the number of concurrent queries and the number of concurrent connections in Managed ClickHouse:
max_concurrent_queriesscales with the plan size, starting at147on the smallest plans.max_connectionsis4000per node.
See Managed ClickHouse® limits and limitations for details.
For querying your ClickHouse® databases, you can use the ClickHouse® client.
Note
Two things in the output can surprise you on a first session:
- A data definition query returns one row per node instead of the empty output stock ClickHouse prints, because it runs as a distributed DDL. See Read the output of a DDL statement.
- A client newer than your service, such as the one in the
clickhouse/clickhouse-serverlatest image, prints anUnknown settingswarning before every result. It is harmless version skew, see Connect to Managed ClickHouse with clickhouse-client.
Query a database with a selected tool
Examples of queries
Retrieve a list of current databases:
SHOW DATABASESCount rows:
SELECT COUNT(*) FROM transactions.expensesCreate a role:
CREATE ROLE accountantQuery a non-replicated table
Startup plans run a single node, so this section applies to the multi-node plans: Business plans run three nodes and Premium plans run six or more.
On those plans, several nodes sit behind the DNS name of your Managed ClickHouse service.
When you query a non-replicated table, for example a log table, requests are routed randomly
to one of the nodes regardless of how data is distributed across them. A particular row is
found only if your SELECT query is directed to the node which executed a WRITE on
this row.
To query a non-replicated table across all the service nodes, use clusterAllReplicas
as follows:
SELECT *
FROM clusterAllReplicas(default, system.query_log)
WHERE query_id = '1a2b3c4d5e6f7g8h9i0j1a2b3c4d5e6f7g8'