Query a remote ClickHouse server
If you have more than one ClickHouse cluster, you might want to send queries from one cluster to another. This is pretty easy in ClickHouse, which has built in support for just that.
remoteSecure) functions can be used in the
FROM clause to read data from a remote server.
To send a query to a specific remote ClickHouse server, you can use
remote. For example:
FROM remote('127.0.0.1:9000', 'default.t1') AS t
WHERE date >= today()
Query id: 1868afed-9689-4605-9675-4be4a7725ea4
│ 14191 │
Similarly, if you have configured remote servers as a cluster in your ClickHouse config, you can send a query to all servers in the remote cluster using the
clusterAllReplicas function. For example:
FROM clusterAllReplicas('clustername', system.mutations)
WHERE NOT is_done
Query id: e53b1851-3246-4d40-8c95-687d3fde5958
command: MATERIALIZE TTL
create_time: 2022-09-19 16:34:24
latest_fail_time: 1970-01-01 00:00:00
1 rows in set. Elapsed: 0.017 sec.