Skip to content
Query Managed ClickHouse® databases

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_queries scales with the plan size, starting at 147 on the smallest plans.
  • max_connections is 4000 per 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:

Query a database with a selected tool

Examples of queries

Retrieve a list of current databases:

SHOW DATABASES

Count rows:

SELECT COUNT(*) FROM transactions.expenses

Create a role:

CREATE ROLE accountant

Query 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'
Last updated on