.

ClickHouse


Reading time: about 1 minute

ClickHouse is a columnar database. It is open-source, licensed under the Apache 2.0 license.

It can be queried with SQL.

chproxy

chproxy is a load-balancing reverse-proxy for ClickHouse.

Since ClickHouse uses HTTP for running queries, you can use any reverse proxy like nginx or HAProxy with it. But chproxy is made specifically for ClickHouse usage.

ClickHouse clusters

You can put ClickHouse servers into clusters to increase your data redundancy, amount of storage, or query performance.

If you are using replication or distributed DDLs, you will need to set up something that implements the ZooKeeper protocol. The best options for ClickHouse are ClickHouse Keeper or ZooKeeper.

Useful links

Interesting queries

Array transpose

create function leoArrayTranspose as (arr) ->
    arrayMap(x -> arrayMap(y -> y[x], arr), arrayEnumerate(arr[1]));

select leoArrayTranspose([
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
])

-- Outputs:
-- [1, 4, 7],
--  [2, 5, 8],
--  [3, 6, 9](https://www.gkbrk.com/1-4-7-2-5-8-3-6-9)

Fast Geo bounding box filtering

WITH
    -1.8822175 AS lon_0,
    53.6256685 AS lat_0,
    1000 AS radius_m,
    radius_m / 110540 AS delta_lat,
    radius_m / (111320 * cos(radians(LEAST(90, ABS(lat_0) + delta_lat)))) AS delta_lon,
    lat_0 - delta_lat AS min_lat,
    lat_0 + delta_lat AS max_lat,
    lon_0 - delta_lon AS min_lon,
    lon_0 + delta_lon AS max_lon
SELECT *
FROM leomap.osm_node
PREWHERE (longitude >= min_lon) AND (longitude <= max_lon) AND (latitude >= min_lat) AND (latitude <= max_lat)
WHERE geoDistance(lon_0, lat_0, longitude, latitude) < radius_m

ClickHouse lexer

The following pages link here

Citation

If you find this work useful, please cite it as:
@article{yaltirakli,
  title   = "ClickHouse",
  author  = "Yaltirakli, Gokberk",
  journal = "gkbrk.com",
  year    = "2025",
  url     = "https://www.gkbrk.com/clickhouse"
}
Not using BibTeX? Click here for more citation styles.
IEEE Citation
Gokberk Yaltirakli, "ClickHouse", August, 2025. [Online]. Available: https://www.gkbrk.com/clickhouse. [Accessed Aug. 24, 2025].
APA Style
Yaltirakli, G. (2025, August 24). ClickHouse. https://www.gkbrk.com/clickhouse
Bluebook Style
Gokberk Yaltirakli, ClickHouse, GKBRK.COM (Aug. 24, 2025), https://www.gkbrk.com/clickhouse

Comments

© 2025 Gokberk Yaltirakli