Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 16 min read How-to mediumAdept

Exploring massive, real-world data sets: 100+ Years of Weather Records in ClickHouse

A billion-row NOAA GHCN climate dataset (1900–2022) is downloaded, filtered on quality flags and pivoted from one measurement per row to one row per station and day using clickhouse-local, then enriched with station coordinates parsed via the Regexp format. The result is loaded into a MergeTree table ordered by station_id and date. A single INFILE insert of about 1.08 billion rows took roughly 196 seconds; splitting the file into 16 parts and inserting in parallel cut that to 135 seconds, which matched the client's disk read limit. Simple queries then confirm historical records such as Furnace Creek's 56.7°C, scanning about 1 billion rows in about 0.1s.

Related posts

  • ClickHouse and The One Billion Row Challenge

    ClickHouse mediumAdept

    ClickHouse Local solves the One Billion Row Challenge (min/mean/max temperature per station from a 13GB text file) in about 20 seconds on an 8-core Hetzner VM, versus nearly 3 minutes for the Java baseline. Reading lines with LineAsString and splitting on ';' instead of using the CSV parser cut the time from 27.6s to 19.9s. Loading into a Memory table first, or precomputing aggregates with a Materialized View into an AggregatingMergeTree via a Null engine, makes later queries near-instant but costs 21–26s of load time, so neither beats the single-scan query end to end. ClickHouse SQL using randCanonical and a Box-Muller transform also generates the dataset 6.8x faster than the Java generator.

  • ClickHouse and The One Trillion Row Challenge

    ClickHouse mediumAdept

    ClickHouse answers Dask's One Trillion Row Challenge (min/avg/max temperature per station over 2.4TiB of Parquet in S3) in under 3 minutes for $0.56 by querying the data in place with the s3 function on an ephemeral cluster of AWS spot instances provisioned and torn down with Pulumi. ARM c7g.12xlarge instances were chosen on spot price per vCPU and availability, since the workload was CPU-bound rather than network-bound. Raising max_download_buffer_size to 50MB so each ~25MB file is fetched by a single thread cut S3 read wait, increased throughput to ~920MB/s and dropped a 111-billion-row test from 454s to 303s, with further thread tuning following. Loading the data into a MergeTree first would answer the query in 16 seconds, at the cost of load time.

  • Getting Data Into ClickHouse - Part 1

    ClickHouse mediumAdept

    ClickHouse can load a 28.7M-row, 4.6GB gzipped Hacker News CSV with a single command, using schema inference via clickhouse-local's file() and the url() table function. Inferred schemas are best-effort, with Nullable Float64 and String types everywhere. Defining explicit types (UInt32, Enum, LowCardinality, DateTime) with ORDER BY id improves the result: loading from a local file with INFILE took about 94s versus 204s streaming from the URL. Sample analytical queries then scan the full table in under 2 seconds, even with ILIKE text filters.

  • ClickHouse Over the Years with Benchmarks

    ClickHouse mediumAdept

    Every ClickHouse release from 1.1.54378 (April 2018) onward was installed on one AWS m5.8xlarge and run through the Star Schema Benchmark, the Brown University benchmark and ClickHouse's own hits benchmark to see how performance changed over time. The setup pulls 328 versions from the old Yandex and new packages.clickhouse.com apt repositories, then exports the hits dataset to CSV with clickhouse-local. Getting the data into old versions meant workarounds for missing features: dropping index_granularity_bytes, replacing LowCardinality with String and IPv4 with String, and splitting DateTime64 into DateTime plus a milliseconds column. Star Schema Benchmark results come with a caveat, since its random value distribution does not resemble real datasets.

  • How Real Estate Analytics made its data pipeline 50x faster with ClickHouse

    ClickHouse easyNovice

    Real Estate Analytics replaced a MongoDB-based architecture with ClickHouse to serve user-selectable slicing across 200+ columns on 3-20 million row tables. In MongoDB each added index increased refresh time by about 10%, and full refreshes took 25-30 minutes. In ClickHouse the same refreshes finish in under 30 seconds (50x), and aggregation queries run about 10x faster. The team also replaced a Kafka-plus-containerized-consumer ingestion path with S3-to-ClickHouse loading, using globs, reading zip files without extracting them, the S3 table function and in-database JSON and regex parsing. Remaining gaps include no support for pre-1900 dates, weak WKT spatial support and, at the time, no auto-increment IDs.

The quest for software engineering knowledge.

Look:
Layout: