Skip to content

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

ClickHouse 7 min read Deep dive hardMaster

Making complex JSON 58x faster, use 3,300x less memory, in ClickHouse

ClickHouse v25.8 adds two new on-disk serializations for the JSON type's shared data, which holds paths beyond the 1,024 dynamic-subcolumn limit. Previously, reading such a path meant loading and filtering an entire Map(String, String) column. A bucketed format hashes paths into separate maps so only one bucket is read. An advanced format adds per-granule .structure, .paths_marks and substream files, so queries can skip granules and seek directly to a path or a nested subcolumn. To keep full-document reads and merges fast, the original map layout is stored alongside the advanced one, roughly doubling storage. On 200k rows with 10k paths, selective reads ran about 58x faster with about 3,300x less memory, and whole-document reads stayed close to the original format.

Assumes: ClickHouse MergeTree partscolumnar storagegranules and marks

Related posts

  • ClickHouse Newsletter April 2022: JSON, JSON, JSON

    ClickHouse mediumAdept

    ClickHouse 22.3 LTS adds an experimental JSON data type that stores semi-structured documents in a single column, with dynamic subcolumns underneath, so you no longer need hand-built schemas of arrays and materialized columns. The worked examples cover querying nested fields, loading files with the JSONAsString format, and pulling a timestamp into its own column so MergeTree has a usable sorting key. They also show how to display field names with output_format_json_named_tuples_as_objects. The release also ships ARM Docker images, fully tested S3 disk storage (with known performance issues), and a Hive table function, and ClickHouse Cloud's serverless waitlist is now open.

  • The billion docs JSON Challenge: ClickHouse vs. MongoDB, Elasticsearch, and more

    ClickHouse mediumAdept

    JSONBench is a reproducible benchmark that loads up to one billion Bluesky event JSON documents into ClickHouse, MongoDB, Elasticsearch, DuckDB and PostgreSQL, then measures storage size and the speed of five analytical queries. ClickHouse's columnar JSON type stores each JSON path as a separate compressed column. In these tests it used 40% less storage and ran aggregations 2500x faster than MongoDB, used half the storage and ran 10x faster than Elasticsearch, and was several thousand times faster than DuckDB and PostgreSQL while using 5-6x less disk. The write-up explains each system's JSON storage model, compression, sorting, indexes and caches, and how each was configured for a fair comparison, such as MongoDB covered index scans and Elasticsearch with _source disabled.

  • How we built a new powerful JSON data type for ClickHouse

    ClickHouse hardMaster

    ClickHouse's new JSON type stores every JSON path as a true columnar, dense subcolumn, built on two standalone building blocks: Variant and Dynamic. Variant keeps mixed-type values in per-type column files without coercing them to a common type, using a UInt8 discriminator column (255 reserved for NULL) and in-memory offsets to locate values. Dynamic removes the need to declare types up front and caps separately stored types with max_types (default 32). Types beyond the cap go into a binary-encoded SharedVariant string column, which keeps sparse or high-cardinality JSON from producing an avalanche of column files on disk.

  • What really matters for performance: lessons from a year of benchmarks

    ClickHouse easyNovice

    Six ClickHouse benchmarks from 2025 point to one conclusion: performance depends on how efficiently an engine moves data end-to-end. JSONBench showed columnar JSON storage running orders of magnitude faster than document stores like MongoDB on up to 1B Bluesky events. FastFormats found the Native format, LZ4 compression and large batches matter most for ingestion, and Netflix used those results to reach ~5 PB/day of log ingestion. A distributed cache matched or beat local SSDs on object storage, lightweight SQL UPDATEs ran up to 1,000× faster than mutations, and parallel replicas aggregated 100B rows in ~0.4s.

  • Christmas gifts from the ClickHouse engineering team

    ClickHouse mediumAdept

    ClickHouse 25.12 ships a batch of end-of-year improvements, from client usability tweaks (digit-group highlighting in the prompt, per-row readable numeric hints) to query engine optimizations. distinctJSONPaths now merges per-part JSON path metadata instead of decoding column data, cutting a 10M-row BlueSky query from 4.56 s to 82 ms. DISTINCT on LowCardinality columns now works on dictionary IDs with early exit, typically 2-6x faster, but slower on a sorting-key column where unique values are spread across the whole table. SEMI JOINs now push filters down via equivalent column sets, giving roughly 30% faster queries and 30% less data read.

The quest for software engineering knowledge.

Look:
Layout: