Solving the "Impossible" in ClickHouse: Advent of Code 2025
All 12 Advent of Code 2025 puzzles are solved in pure ClickHouse SQL, each as a single query that parses the raw input and computes both parts with no UDFs, temporary tables or preprocessing. Imperative patterns are mapped onto ClickHouse features: window functions such as sum() OVER and lagInFrame turn simulations into running totals, arrayJoin with range expands compact ranges into rows, arrayExists with lambdas detects repeating patterns, and arrayFold carries accumulator state for greedy algorithms. Every day includes the full commented CTE-chained query, showing how far ClickHouse's array and higher-order functions can stretch beyond OLAP workloads.
Related posts
- ClickHouse Newsletter March 2023: Contributing to ClickHouse
ClickHouse mediumAdept
ClickHouse v23.2 ships 18 new features, 30 performance optimisations and 43 bug fixes, headlined by multi-stage PREWHERE, read support for Apache Iceberg v1 tables, and correlation matrix computation. The featured query counts cumulative unique contributors to ClickHouse repositories from GitHub events. A first version uses groupArrayDistinct with a window function over monthly arrays. A more concise version passes uniqState sketches from a subquery and merges them cumulatively with uniqMerge in a window, cutting runtime from 32ms to 24ms. The issue closes with a reading list and upcoming webinars and meetups.
- ClickHouse Release 26.4
ClickHouse mediumAdept
ClickHouse 26.4 ships 39 features, 45 performance optimizations and 238 bug fixes, led by SQL-compatibility additions: VALUES as a table expression with column aliases, PostgreSQL-style EXTRACT units, SET TIME ZONE, NATURAL JOIN and compound INTERVAL literals. LIKE '%token%' queries can now scan the text index dictionary instead of the full column, which ran about 3x faster with far less memory on the HackerNews dataset. COUNT DISTINCT (uniqExact) merges all per-thread two-level hash tables in a single pass and stops spawning redundant threads, giving 3-15x speedups on a 288-core machine but nothing on a 12-core laptop. EXPLAIN pretty output is more readable, and a new JSONAllValues function lets a text index cover every leaf value of a JSON column.
- ClickHouse Release 26.7
ClickHouse mediumAdept
ClickHouse 26.7 ships 61 features, 112 performance optimizations and 329 bug fixes, led by a fused ordered-aggregation pipeline that pushes LIMIT into in-order GROUP BY. On TPC-H SF100 it made a Top-N order-summary query 313× faster with 592× less memory by stopping reads once N groups complete. JOIN gains include runtime filters from the build side that skip probe-side granules via primary-key and skip-index analysis (6.2× faster on a selective TPC-H join), compact 8-byte row references in hash tables (median 12% faster, 15% less memory), and a new dpsub join-ordering algorithm that can chain with greedy as a fallback. Vector search also improves through QBit additions such as Int8 support, strided storage, randomized Hadamard rotations and quantization codecs, alongside phrase search, EXPLAIN ANALYZE and unified URL access.
- ClickHouse Release 23.10
ClickHouse mediumAdept
ClickHouse 23.10 ships 23 new features, 26 performance optimisations and 60 bug fixes. Highlights include a largestTriangleThreeBuckets aggregate for downsampling time series while preserving local minima and maxima, demonstrated on the SF Bay Area Bike Share dataset. Also new are arrayFold, a left-fold higher-order array function, shown reconstructing versioned text from per-line change history, and native ingestion of Numpy .npy files, which lets LAION embeddings be joined with Parquet metadata using clickhouse local instead of Python. Smaller additions include SHOW MERGES/SHOW SETTINGS, jsonMergePatch, formatQuery, argMin/argMax combinators and tables without a primary key.
- ClickHouse Newsletter July 2023: Seeing Clearly
ClickHouse mediumAdept
ClickHouse v23.6 adds 10 features, 12 performance optimisations and 31 bug fixes. Highlights include exploiting natural sort order in almost-sorted columns that aren't in the ordering key, MongoDB integration support up to v6, and a transform function that now works with all data types. The query of the month uses the windowFunnel function on the GitHub Events dataset for a fork-to-PR funnel analysis. About 17% of ClickHouse forkers open a PR within 30 days, which ranks 22nd among repositories with more than 25k stars and 5k forks. The rest of the issue is links and upcoming meetups and trainings.