The release arrived before the turkey. The blog post took a little longer, but now that we’ve worked our way through the leftovers, it’s time to explore ClickHouse 26.11.
The ClickHouse 26.11 release contains 95 new features 🥧 364 performance optimizations 🌽 and 932 bug fixes 🧣.
In this release, ClickHouse becomes a fully static binary and adds support for reading and writing Vortex files. The new default JOIN optimizer finds more efficient ways to join your tables, while improvements to the adaptive aggregator help speed up GROUP BY queries.
We also extend the experimental columns cache to Parquet, cut unnecessary requests when reading Iceberg tables, and introduce INSERT ... RETURNING so you can inspect or summarise data as it’s ingested.
New contributors
A special welcome to all the new contributors in 26.11! The growth of ClickHouse's community is humbling, and we are always grateful for the contributions that have made ClickHouse so popular.
Below are the names of the new contributors:
2919035, Aathithya Arasu S, Adam Albastov, Adegbite Ayoade, Akhilesh Aji, Alex Parker, Andrew Dunn, Andrey Chudnovskiy, Andrey Istratov, AnkitNakhawa, ArtemovMichael, Aykhan Shahsuvarov, Benjamin Brown, Bojan Djurkovic, Brian Deitte, Chiranmoy Bhattacharya, Colton Shepard, CountDocula, Daniel Sangorrin, Daria Zhukova, David Mischke, David Rozenfeld, Deepak Divya Tejaswi, Dmitry Tsybin, Drew Hammond, Edouard Oger, Elizabet Oliveira, Eric Chen, Eric Kurbanov, Foad Lotfifar, Garen J. Torikian, GertL, Hafiar, Henry Su, Joel Bandi, John Tanzer, Johnny Metz, Jonathan Albrecht, Juan Ruiz Gomez, Julia Vallina, Kaili Gu, Karissa Van Baulen, Kelsey Schlarman, Ken Hu, Kevin Biju, Kirill Kopienko, Kristóf Szerencsi, Lavkush Kumar, Lazizbek Ergashev, Luke, MakerYuichi, Marcos Panichella, Mark Dawson, Marouane-elfadli, Mihai Zegheru, Mike Heffner, Mikhail Kot, Mishel Veksler, Mohd Irshad, Muhammad Soliman, Neeraj Upadhyay, Oleg Kruglov, Omar Eladawy, Piotr Kubaj, Praveen Kumar, Pulk17, RagamuffinCat, Raphaël, Ravi Kumar L, Refael, RiaK912, Ricardo Muhlstedt, Ryan Cunningham, Saad Khan, Serafym Honcharov, Shadow88Mornach, Shajahan Palayil, Shashwat Pratap, Sridhar Muruganandham, Steven Stone, Sven Eliasson, Taeknology, Tyagiquamar, Ugo Sangiorgi, Wegz, Yan Alexandre, Yaroslav Briukhovetskyi, Ye Yuan, Yechezkel Rabinovich, Young, YoungjuKim, alwaysprince05, anton.yakushev, aq1u, bhive9, bunjj, ch-samuel-reviewer-1, clickhouse-cloud-ci[bot], danbugs, duongynhi000005-oss, euvre, fabiovincenzi, franchb, heitzlki, kaguya sama, kolsha, lazerg, lureilly1, mikakot, mohammedImad10, mu-soliman, noob, pratyush-anand1444, rksrinivasan-striim, rohity, serprex, shubhamojha1, singhpratech, starpact, syoshida20, trusty-tiger, vevan05, wangchenguang, wangshun, xnervwang, xuir268, zhao-xiaogang
Hint: if you’re curious how we generate this list… here.
You can also view the slides from the presentation.
A fully static binary
Contributed by Konstantin Bogdanov
ClickHouse has long shipped as a single executable, but on Linux it still depended on shared libraries installed on the host. ClickHouse 26.11 removes that dependency: the Linux binaries for x86-64 and ARM64 are now statically linked using musl libc.
We can see the difference with ldd, which lists an executable's shared-library dependencies. Let's check the ARM64 binary in the 26.10 Docker image:
docker run --rm --entrypoint ldd \
clickhouse/clickhouse-server:26.10.11.12 /usr/bin/clickhouselinux-vdso.so.1 (0x0000ffffb0448000)
librt.so.1 => /lib/aarch64-linux-gnu/librt.so.1 (0x0000ffff89c80000)
libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000ffff89c60000)
libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000ffff89ab0000)
/lib/ld-linux-aarch64.so.1 (0x0000ffffb0410000)
libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000ffff89a10000)
libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000ffff899f0000)And now, let's do the same check with 26.11:
docker run --rm --entrypoint ldd \
clickhouse/clickhouse-server:26.11.2.4 /usr/bin/clickhousestatically linkedFaster adaptive aggregator
Contributed by Nihal Miaji
ClickHouse 26.8 introduced the adaptive aggregator by default, which speeds up GROUP BY queries with many distinct keys. ClickHouse 26.11 makes it faster: a 1.62x average speedup with 64 threads across 13 ClickBench aggregation queries. For aggregation that spills to disk, we observed an average speedup of 5.83x.
This improvement builds on how the adaptive aggregator works: instead of letting each thread's hash table grow with the number of distinct keys, it stops adding new keys once a thread’s table contains 16,384 keys (adaptive_aggregator_freeze_threshold). Rows with new keys are set aside and inserted only once during the merge into the final result. We further optimized this process with fewer writes and a smaller footprint.
Let’s try it with 100 million generated page views from about 20 million visitors:
CREATE TABLE page_views
ORDER BY view_time
AS SELECT
number AS view_id,
cityHash64(number) % 20000000 AS visitor_id,
toDateTime('2026-11-01 00:00:00') + intDiv(number, 40) AS view_time,
['AU', 'US', 'DE', 'IN', 'BR', 'JP', 'GB', 'FR'][cityHash64(number, 1) % 8 + 1] AS country
FROM numbers(100000000);To find the visitors with the most page views, we group by visitor_id, a common pattern with many distinct keys:
SET enable_adaptive_aggregator = 1; -- enabled by default
SELECT visitor_id, count() AS views
FROM page_views
GROUP BY visitor_id
ORDER BY views DESC
LIMIT 10;The adaptive aggregator is enabled by default (enable_adaptive_aggregator = 1). We toggled this setting on and off and ran the query three times. With 24 threads, the query time and peak memory from system.query_log were:
| Aggregator type | Run | Query time | Peak memory |
|---|---|---|---|
| Non-adaptive | 1 | 907 ms | 6.01 GiB |
| Non-adaptive | 2 | 894 ms | 6.01 GiB |
| Non-adaptive | 3 | 910 ms | 6.00 GiB |
| Adaptive | 1 | 240 ms | 669.37 MiB |
| Adaptive | 2 | 239 ms | 664.63 MiB |
| Adaptive | 3 | 246 ms | 667.77 MiB |
In this example, the adaptive aggregator ran the query about 3.8x faster and used about 1/9 of peak memory.
New default JOIN optimizer
Contributed by Fisnik Kastrati
ClickHouse 26.11 enables the new cost-based JOIN optimizer by default. The order in which tables are joined can make a big difference: applying a selective join early can reduce the number of rows that later joins need to process, saving time and memory without changing the query's result.
The optimizer uses a dynamic-programming algorithm called DPsub to compare alternative join orders and choose the plan with the lowest estimated cost. The previous greedy approach made one choice at a time, which could lead to a more expensive overall plan.
It also extends join reordering to LEFT, RIGHT, and FULL outer joins, as well as SEMI and ANTI joins. Since changing the order of these joins can change the result, a conflict detector ensures that only valid reorderings are considered.
Columns cache for Parquet
Contributed by Alexey Milovidov
ClickHouse 26.10 introduced the experimental columns cache for native tables. The columns cache keeps deserialized column data in memory, saving subsequent queries from decompressing and deserializing it again. ClickHouse 26.11 extends the experimental columns cache to Parquet files, including those read from local disk and object storage. Subsequent queries can reuse deserialized column data without reading, decompressing, and decoding it again.
Let's try it with the Amazon reviews dataset, which is available as multiple Parquet files in a public S3 bucket.
The following query computes the number of reviews, average rating, and number of helpful votes by product category and verified purchase status for 2010 and 2011:
SELECT
product_category,
verified_purchase,
count() AS reviews,
round(avg(star_rating), 2) AS average_rating,
sum(helpful_votes) AS helpful_votes
FROM s3(
's3://datasets-documentation/amazon_reviews/amazon_reviews_{2010,2011}.snappy.parquet'
)
GROUP BY product_category, verified_purchase
ORDER BY reviews DESC, product_category, verified_purchase
LIMIT 10
SETTINGS use_columns_cache = 0,
use_query_cache = 0,
use_query_condition_cache = 0,
enable_filesystem_cache = 0,
log_queries = 1,
log_profile_events = 1,
log_comment = 'parquet-columns-cache:example';| product_category | verified_purchase | reviews | average_rating | helpful_votes |
|---|---|---|---|---|
| Books | false | 1221938 | 4.17 | 5232371 |
| Books | true | 1156799 | 4.33 | 4166921 |
| PC | true | 505966 | 4.08 | 1453627 |
| Wireless | true | 413310 | 3.72 | 758628 |
| Video DVD | true | 311918 | 4.3 | 953397 |
| Digital_Ebook_Purchase | true | 272165 | 3.91 | 1237395 |
| Kitchen | true | 267198 | 4.16 | 1324710 |
| Home | true | 265270 | 4.05 | 1310969 |
| Electronics | true | 250684 | 3.99 | 702293 |
| Sports | true | 249365 | 4.12 | 1001795 |
As in the 26.10 release post, we'll do one unmeasured warm-up, followed by three times with caching disabled, using log comments parquet-columns-cache:off-1, parquet-columns-cache:off-2, and parquet-columns-cache:off-3. Then we'll change use_columns_cache to 1 and repeat with comments parquet-columns-cache:on-1, parquet-columns-cache:on-2, and parquet-columns-cache:on-3.
The first enabled run populates the columns cache; the next two can reuse it.
We can retrieve the timings and cache counters from the query log, by running the following query:
SELECT
log_comment AS run,
query_duration_ms AS queryTime,
ProfileEvents['ColumnsCacheHits'] AS cacheHits,
ProfileEvents['ColumnsCacheMisses'] AS cacheMisses,
read_rows AS readRows
FROM
(
SELECT *
FROM system.query_log
WHERE type = 'QueryFinish'
AND startsWith(log_comment, 'parquet-columns-cache:')
AND log_comment != 'parquet-columns-cache:warmup'
ORDER BY query_start_time_microseconds DESC
LIMIT 6
)
ORDER BY query_start_time_microseconds
FORMAT Markdown;| run | queryTime | cacheHits | cacheMisses | readRows |
|---|---|---|---|---|
| parquet-columns-cache:off-1 | 7287 | 0 | 0 | 9980967 |
| parquet-columns-cache:off-2 | 9503 | 0 | 0 | 9980967 |
| parquet-columns-cache:off-3 | 11125 | 0 | 0 | 9980967 |
| parquet-columns-cache:on-1 | 8069 | 0 | 68 | 9980967 |
| parquet-columns-cache:on-2 | 221 | 68 | 0 | 9980967 |
| parquet-columns-cache:on-3 | 118 | 68 | 0 | 9980967 |
With the columns cache disabled, the best run took 7.3 seconds, compared to 118 milliseconds with the cache enabled.
We can see on the last two rows that there were 68 cache hits. To see where those 68 hits come from, we can inspect system.columns_cache:
SELECT column, count() AS cache_entries, sum(rows) AS cached_rows
FROM system.columns_cache
GROUP BY column
ORDER BY column
FORMAT Markdown;| column | cache_entries | cached_rows |
|---|---|---|
| helpful_votes | 17 | 9980967 |
| product_category | 17 | 9980967 |
| star_rating | 17 | 9980967 |
| verified_purchase | 17 | 9980967 |
When working with Parquet files, each cache entry contains one decoded output column per row group. The 2010 file has 7 row groups and the 2011 file has 10, giving us 17 in total.
Our query reads four columns across all 17 row groups. Once the cache is populated, subsequent runs reuse 4 columns × 17 row groups = 68 cache entries, resulting in 68 cache hits.
Reading and writing Vortex files
Contributed by Alexey Milovidov and Maksim Dergousov
ClickHouse 26.11 adds support for reading and writing Vortex files. Vortex is an open-source columnar file format designed for fast scans, random access, and compression.
Let's try it with FineWeb, Hugging Face's collection of cleaned and deduplicated English web text for training language models. A Vortex conversion is available on Hugging Face. We'll download one 1.53 GB shard from its 10-billion-token sample. The 10BT name refers to tokens across the sample; this individual file contains just over a million web pages.
We can download one of the files by running the following:
mkdir -p data output
curl -L --fail \
'https://huggingface.co/datasets/vortex-data/fineweb/resolve/b04ab34c10c8a9e1a88767ea951d9a81e006277d/vortex/sample/10BT/000_00000.vortex' \
-o data/fineweb.vortexLet's then launch ClickHouse and inspect the schema by directly querying the file:
DESCRIBE file('data/fineweb.vortex', Vortex)
SETTINGS describe_compact_output = 1;┌─name───────────┬─type──────────────┐
│ text │ Nullable(String) │
│ id │ Nullable(String) │
│ dump │ Nullable(String) │
│ url │ Nullable(String) │
│ date │ Nullable(String) │
│ file_path │ Nullable(String) │
│ language │ Nullable(String) │
│ language_score │ Nullable(Float64) │
│ token_count │ Nullable(Int64) │
└────────────────┴───────────────────┘Each row contains a page's text and URL, along with crawl metadata, a language-identification score, and a token count. We can count the pages like this:
SELECT count() AS web_pages
FROM file('data/fineweb.vortex', Vortex);┌─web_pages─┐
│ 1048581 │
└───────────┘ClickHouse can answer this count from the file's metadata. To look at some actual values, we'll select the domain, token count, and language score for five pages:
SELECT
domain(url) AS website,
token_count,
round(language_score, 3) AS language_score
FROM file('data/fineweb.vortex', Vortex)
LIMIT 5;The language_score indicates confidence in the language classification, rather than the quality of the page. We can also aggregate over the file to find the most common websites and their average page lengths:
SELECT
domain(url) AS website,
count() AS pages,
round(avg(token_count)) AS average_tokens
FROM file('data/fineweb.vortex', Vortex)
GROUP BY website
ORDER BY pages DESC, website
LIMIT 10;┌─website─────────────────┬─pages─┬─average_tokens─┐
│ en.wikipedia.org │ 1170 │ 2291 │
│ www.theguardian.com │ 838 │ 947 │
│ bleacherreport.com │ 686 │ 779 │
│ www.prweb.com │ 654 │ 624 │
│ www.fanfiction.net │ 613 │ 2023 │
│ www.businessinsider.com │ 536 │ 611 │
│ www.washingtonpost.com │ 505 │ 959 │
│ www.huffingtonpost.com │ 502 │ 773 │
│ www.nytimes.com │ 473 │ 1056 │
│ www.csmonitor.com │ 452 │ 870 │
└─────────────────────────┴───────┴────────────────┘English Wikipedia is the most common domain in this shard. We can write the following query to count the number of pages and total tokens for that domain:
SELECT
count() AS english_wikipedia_pages,
sum(token_count) AS tokens
FROM file('data/fineweb.vortex', Vortex)
WHERE domain(url) = 'en.wikipedia.org';┌─english_wikipedia_pages─┬─tokens──┐
│ 1170 │ 2680162 │
└─────────────────────────┴─────────┘To export all the English Wikipedia rows to a new Vortex file, we can write the following query:
SELECT *
FROM file('data/fineweb.vortex', Vortex)
WHERE domain(url) = 'en.wikipedia.org'
INTO OUTFILE 'output/wikipedia.vortex';ClickHouse infers the output format from the .vortex extension. We could also specify FORMAT Vortex explicitly after the filename.
Now let's read the exported file and check that it contains the same number of pages and tokens:
SELECT
count() AS english_wikipedia_pages,
sum(token_count) AS tokens
FROM file('output/wikipedia.vortex', Vortex);┌─english_wikipedia_pages─┬─tokens──┐
│ 1170 │ 2680162 │
└─────────────────────────┴─────────┘Finally, we can inspect a few of the exported URLs:
SELECT
substring(url, 1, 100) AS url,
token_count
FROM file('output/wikipedia.vortex', Vortex)
ORDER BY url, id
LIMIT 5;┌─url─────────────────────────────────────────────────────────┬─token_count─┐
│ http://en.wikipedia.org/wiki/106_%26_Park │ 2021 │
│ http://en.wikipedia.org/wiki/1373 │ 855 │
│ http://en.wikipedia.org/wiki/1525 │ 1117 │
│ http://en.wikipedia.org/wiki/1913_college_football_season │ 123 │
│ http://en.wikipedia.org/wiki/1928_Atlantic_hurricane_season │ 2176 │
└─────────────────────────────────────────────────────────────┴─────────────┘Array permutations and combinations
Contributed by Michael Artemov
ClickHouse 26.11 adds three functions for generating permutations and combinations of array elements. Let's use them to explore different ways to display three products on a storefront.
If we want to display all three products, arrayPermutations returns every possible ordering:
SELECT arrayPermutations(['book', 'mug', 'shirt']) AS layouts;[['book','mug','shirt'],['book','shirt','mug'],['mug','book','shirt'],
['mug','shirt','book'],['shirt','book','mug'],['shirt','mug','book']]Now suppose we have only two featured positions. arrayPartialPermutations takes the number of positions as its second argument:
SELECT arrayPartialPermutations(['book', 'mug', 'shirt'], 2) AS featured_pairs;[['book','mug'],['book','shirt'],['mug','book'],
['mug','shirt'],['shirt','book'],['shirt','mug']]There are six possibilities because the order matters: featuring a book first and a mug second is a different layout from featuring a mug first and a book second.
For a two-product bundle, we care about which products are included, but not their order. arrayCombinations gives us those three choices:
SELECT arrayCombinations(['book', 'mug', 'shirt'], 2) AS bundles;[['book','mug'],['book','shirt'],['mug','shirt']]These functions work with array positions, so if you have an array with the same value multiple times, you'll see it repeated in the output. For example, arrayCombinations(['book', 'book', 'mug'], 2) returns [['book','book'],['book','mug'],['book','mug']].
As you might imagine, the number of results can grow quickly: function_range_max_elements_in_block limits the generated elements.
Functions for JSON strings
Contributed by Minh Vu and Rohit
The JSON string functions highlighted in this release help us remove fields, search values across a nested document, and identify the paths those values came from.
JSONRemove, also available as JSON_REMOVE, removes object members or array elements using JSONPath expressions. For example, we can remove a session token and the first tag while keeping the rest of the event:
WITH '{
"user": "alice",
"session": {
"token": "demo-token",
"device": "mobile"
},
"tags": ["internal", "checkout"]
}' AS event
SELECT prettyPrintJSON(
JSONRemove(event, '$.session.token', '$.tags[0]')
) AS cleaned
FORMAT PrettyCompact;┌─cleaned────────────────────┐
│ { ↴│
│↳ "user": "alice", ↴│
│↳ "session": { ↴│
│↳ "device": "mobile"↴│
│↳ }, ↴│
│↳ "tags": [ ↴│
│↳ "checkout" ↴│
│↳ ] ↴│
│↳} │
└────────────────────────────┘prettyPrintJSON formats the returned JSON string so we can read it inside the result table.
JSONExtractLeafValues extracts the scalar values from a JSON object, including values inside nested objects and arrays:
WITH '{
"level": "error",
"message": "payment declined",
"context": {
"service": "checkout",
"codes": [402, 429]
}
}' AS event
SELECT JSONExtractLeafValues(event) AS values;['error','payment declined','checkout','402','429']The result is an array of strings, so the numeric codes become strings too.
For searches across all values, we can use JSONExtractLeafValues in a text index:
CREATE TABLE logs
(
timestamp DateTime,
body String,
INDEX body_text JSONExtractLeafValues(body)
TYPE text(tokenizer = 'splitByNonAlpha')
)
ORDER BY timestamp;
INSERT INTO logs VALUES
('2026-11-26 10:00:00', '{"level":"info","message":"request started","context":{"service":"checkout"}}'),
('2026-11-26 10:00:01', '{"level":"error","message":"payment declined","context":{"service":"checkout","codes":[402,429]}}'),
('2026-11-26 10:00:02', '{"level":"info","message":"email sent","context":{"service":"notifications"}}');We can now use hasAnyTokens to find events containing the token checkout, even though it appears in a nested field:
SELECT count() AS matching_logs
FROM logs
WHERE hasAnyTokens(JSONExtractLeafValues(body), 'checkout');┌─matching_logs─┐
│ 2 │
└───────────────┘We can see the query plan by prefixing the query with EXPLAIN indexes=1:
┌─explain───────────────────────────────────────────────────────────────────────────────────┐
│ Output: count() │
│ │
│ Aggregating │
│ │ Keys: │
│ │ Aggregates: count() │
│ │ Skip merging: 0 │
│ └──ReadFromTextIndexCount (Trivial count from text index (body_text, token = "checkout")) │
└───────────────────────────────────────────────────────────────────────────────────────────┘The ReadFromTextIndexCount operator shows that ClickHouse answers the query directly from the text index.
If we also want to know where each value came from, JSONExtractLeafPathsAndValues returns a (path, value) tuple for each leaf:
WITH '{
"level": "error",
"message": "payment declined",
"context": {
"service": "checkout",
"codes": [402, 429]
}
}' AS event
SELECT JSONExtractLeafPathsAndValues(event) AS paths_and_values;[('level','error'),('message','payment declined'),
('context.service','checkout'),('context.codes[0]','402'),
('context.codes[1]','429')]Nested paths use dots, and array elements include their index. The return type is Array(Tuple(path String, value String)), with values represented as strings.
We can also use JSONExtractLeafPathsAndValues to build an index for exact path/value matches. For example, we might want to find logs where context.service is checkout, keeping that separate from a screen or another field with the same value.
A text index cannot index the returned tuples directly. We'll use arrayMap to encode each pair as a JSON string with toJSONString and tuple, giving us an Array(String), and use the array tokenizer to treat each complete pair as one token:
CREATE TABLE logs_by_field
(
timestamp DateTime,
body String,
fields Array(String) ALIAS arrayMap(
pair -> toJSONString(tuple(pair.1, pair.2)),
JSONExtractLeafPathsAndValues(body)
),
INDEX fields_text fields TYPE text(tokenizer = 'array')
)
ORDER BY timestamp;
INSERT INTO logs_by_field VALUES
('2026-11-26 10:00:00', '{"level":"info","message":"request started","context":{"service":"checkout"}}'),
('2026-11-26 10:00:01', '{"level":"error","message":"payment declined","context":{"service":"checkout","codes":[402,429]}}'),
('2026-11-26 10:00:02', '{"level":"info","message":"email sent","context":{"service":"notifications","screen":"checkout"}}');The first two events have checkout at context.service; the third has it at context.screen. Each pair becomes a string such as ["context.service","checkout"]. Encoding both components together preserves the association between the path and its value.
We can now search for the exact pair using has:
SELECT count() AS matching_logs
FROM logs_by_field
WHERE has(fields, toJSONString(tuple('context.service', 'checkout')));┌─matching_logs─┐
│ 2 │
└───────────────┘New geo functions
Contributed by Pulkit Chauhan
ClickHouse 26.11 adds seven geo functions for measuring lines, accessing parts of geometries, and finding a rotated bounding rectangle.
Let's start with a line connecting London, Oxford, and Bristol. We can represent it as a LineString, with each point given as (longitude, latitude) in degrees. We'll use a couple of new functions to compute the distance of this line:
lengthSpheroidmeasures the line on the WGS84 spheroid, the model of the Earth used by GPS, and returns metres. Each segment follows the shortest path between its endpoints on that spheroid.lengthSphericaluses a spherical model and returns an angle in radians. Multiplying that result by the mean Earth radius, 6,371,008.8 metres, gives an approximate distance in metres.
WITH [
(-0.1276, 51.5072), -- London
(-1.2577, 51.7520), -- Oxford
(-2.5879, 51.4545) -- Bristol
]::LineString AS route
SELECT
round(lengthSpheroid(route) / 1000, 2) AS distance_km,
round(lengthSpherical(route), 6) AS angular_distance_radians;| distance_km | angular_distance_radians |
|---|---|
| 180.78 | 0.028293 |
For coordinates on a plane, lengthCartesian returns the sum of the Euclidean distances between consecutive points, in the units of those coordinates. For example, a route on a warehouse floor plan measured in metres:
WITH [(0, 0), (3, 4), (3, 10)]::LineString AS route
SELECT lengthCartesian(route) AS distance_metres;┌─distance_metres─┐
│ 11 │
└─────────────────┘The first segment is 5 metres long and the second is 6 metres. lengthCartesian is also available as ST_Length.
Three more functions let us access individual parts of a geometry. Suppose we have a rectangular building with a courtyard. Its Polygon contains an outer ring followed by an inner ring representing the courtyard.
exteriorRingreturns the outer boundaryinteriorRingNselects a holepointNselects a point from a line or ring. Both numbered functions count from 1.
Their aliases are ST_ExteriorRing, ST_InteriorRingN, and ST_PointN.
WITH [
[(0, 0), (12, 0), (12, 8), (0, 8), (0, 0)],
[(4, 2), (8, 2), (8, 6), (4, 6), (4, 2)]
]::Polygon AS building
SELECT
exteriorRing(building) AS outer_boundary,
interiorRingN(building, 1) AS courtyard_boundary,
pointN(exteriorRing(building)::LineString, 2) AS second_corner;| outer_boundary | courtyard_boundary | second_corner |
|---|---|---|
[(0,0),(12,0),(12,8),(0,8),(0,0)] | [(4,2),(8,2),(8,6),(4,6),(4,2)] | (12,0) |
Finally, polygonMinimumRotatedRectangleCartesian finds the smallest-area rectangle enclosing a geometry in Cartesian coordinates. The rectangle can rotate to fit the geometry.
Let's apply it to an irregular site outline. The function returns a Polygon; we'll extract its outer ring and round the coordinates for display:
WITH [[(0, 0), (2, 1), (4, 4), (1, 3), (0, 0)]]::Polygon AS site
SELECT arrayMap(
point -> (round(point.1, 2), round(point.2, 2)),
polygonMinimumRotatedRectangleCartesian(site)[1]
) AS bounding_rectangle_corners;[(-0.69,0.46),(2.38,5.08),(4,4),(0.92,-0.62),(-0.69,0.46)]The result contains the four corners, with the first point repeated to close the ring.
Random ordering with SHUFFLE
Contributed by kaguya sama and koz9va
ClickHouse 26.11 introduces the experimental SHUFFLE clause. We can use it in place of ORDER BY rand() to return rows in a uniformly random order. When used with LIMIT, it returns a random sample.
Let's try it on the Amazon reviews from 2010 and 2011 that we saw earlier, this time loaded into a ClickHouse table. Assuming that we have those Parquet files in data/, we can create the table like this:
CREATE TABLE amazon_reviews
ORDER BY (product_category, review_date, review_id)
AS SELECT
review_id,
toDate(review_date) AS review_date,
product_id,
product_category,
star_rating,
product_title,
review_headline,
review_body
FROM file('data/amazon_reviews_{2010,2011}.snappy.parquet');The following query returns ten random reviews:
SET allow_experimental_shuffle_query = 1;
SELECT review_id, product_category, star_rating
FROM amazon_reviews
SHUFFLE
LIMIT 10;Each execution returns a different set of reviews. When we include a LIMIT, ClickHouse uses reservoir sampling in each stream and merges the samples, rather than sorting all the rows by a random key. We can see this in the full query pipeline, which we can get by prefixing the query with EXPLAIN PIPELINE:
┌─explain─────────────────────────────────────────────────────────────────────┐
│ (Expression) │
│ ExpressionTransform │
│ (Expression) │
│ ExpressionTransform │
│ (JoinLazyColumnsStep) │
│ LazyMaterializingTransform 2 → 1 │
│ (Limit) │
│ Limit │
│ (Shuffle) │
│ MergingShuffledTransform 12 → 1 │
│ ReservoirSampleTransform × 12 │
│ (Expression) │
│ ExpressionTransform × 12 │
│ (ReadFromMergeTree) │
│ MergeTreeSelect(pool: ReadPool, algorithm: Thread) × 12 0 → 1 │
│ (LazilyReadFromMergeTree) │
│ LazyReadFromMergeTreeSource 0 → 1 │
└─────────────────────────────────────────────────────────────────────────────┘ReservoirSampleTransform samples rows in each stream, and MergingShuffledTransform combines those samples.
SHUFFLE is useful for a small sample like this, but it cannot spill to disk. Without a LIMIT, it keeps the rows being shuffled in memory. With LIMIT n, each stream retains a sample of up to n rows, which means the query might require a lot of memory if we have a large sample or wide rows.
When we need a disk fallback, we can fall back to our trusty ORDER BY rand(), which uses external sorting when necessary. External sorting writes sorted batches to temporary files when a configured memory threshold is reached, then merges them. Smaller queries can still run entirely in memory.
If we know the query fits in memory, we can also make ORDER BY rand() use the shuffle implementation by disabling external sorting and enabling query_plan_use_shuffle_for_order_by_rand:
SELECT review_id, product_category, star_rating
FROM amazon_reviews
ORDER BY rand()
LIMIT 10
SETTINGS query_plan_use_shuffle_for_order_by_rand = 1,
max_bytes_before_external_sort = 0,
max_bytes_ratio_before_external_sort = 0;INSERT ... RETURNING
Contributed by Tyler Hannan and Alexey Milovidov
ClickHouse 26.11 introduces INSERT ... RETURNING, which runs a SELECT over the data being inserted and returns its result as part of the same query. We can use it to get a summary of an ingestion batch, including values generated by DEFAULT and MATERIALIZED expressions.
Let's reuse the Amazon reviews dataset, this time loading all the reviews from 2010 into a new table:
CREATE TABLE amazon_reviews_ingest
(
review_date Date,
review_id String,
product_category LowCardinality(String),
star_rating UInt8,
verified_purchase Bool,
ingested_at DateTime64(3) DEFAULT now64(),
positive Bool MATERIALIZED star_rating >= 4
)
ORDER BY (product_category, review_date);The ingested_at column records when we insert the reviews, while positive identifies ratings of four stars or more - neither column needs to be supplied by the input file.
Assuming the 2010 Parquet file is in data/, we'll insert all its reviews and return their date range, average rating, and number of positive reviews:
INSERT INTO amazon_reviews_ingest
(review_date, review_id, product_category, star_rating, verified_purchase)
RETURNING (
SELECT
count() AS inserted_reviews,
min(review_date) AS first_review,
max(review_date) AS last_review,
round(avg(star_rating), 2) AS average_rating,
countIf(positive) AS positive_reviews,
max(ingested_at) AS ingested_at
FROM amazon_reviews_ingest
)
SELECT
toDate(review_date),
review_id,
product_category,
star_rating,
verified_purchase
FROM file('data/amazon_reviews_2010.snappy.parquet');The RETURNING clause goes before the source SELECT. The file stores review_date as a number of days since the Unix epoch, so we convert it to a Date during ingestion.
| inserted_reviews | first_review | last_review | average_rating | positive_reviews | ingested_at |
|---|---|---|---|---|---|
| 3868472 | 2010-01-01 | 2010-12-31 | 4.07 | 2929349 | 2026-11-26 16:57:48.660 |
The result includes both generated columns: we count positive reviews using positive and return the latest ingested_at timestamp.
Inside the RETURNING clause, FROM amazon_reviews_ingest refers to the incoming batch, rather than all the rows already stored in the table.
Quotas over profile events
Contributed by Alexey Milovidov
Quotas let us limit a user's resource consumption across queries over a time interval. ClickHouse 26.11 extends quotas to any profile event, using the counter names exposed by system.events.
Let's use this to give an analyst a daily budget for S3 GET requests. We'll query the same Amazon reviews Parquet files that we used in the columns cache example.
First, as an administrator, we'll create an analyst account and grant the permissions needed to use the s3 table function:
CREATE USER review_analyst
IDENTIFIED BY 'demo-password';
GRANT S3, CREATE TEMPORARY TABLE ON *.* TO review_analyst;We can then assign a quota using the S3GetObject profile event:
CREATE QUOTA review_s3_budget
FOR INTERVAL 1 day
MAX S3GetObject = 30
TO review_analyst;This gives the analyst a budget of 30 S3 GET requests per day, shared across their queries and connections. We've chosen a small number so that we can see the quota being exceeded after just a few queries.
Let's then connect to ClickHouse as review_analyst and run the review aggregation from earlier:
SELECT
product_category,
verified_purchase,
count() AS reviews,
round(avg(star_rating), 2) AS average_rating,
sum(helpful_votes) AS helpful_votes
FROM s3(
's3://datasets-documentation/amazon_reviews/amazon_reviews_{2010,2011}.snappy.parquet',
NOSIGN
)
GROUP BY product_category, verified_purchase
ORDER BY reviews DESC, product_category, verified_purchase
LIMIT 10
SETTINGS use_columns_cache = 0,
use_query_cache = 0,
use_query_condition_cache = 0,
enable_filesystem_cache = 0,
use_parquet_metadata_cache = 0,
schema_inference_use_cache_for_s3 = 0;We've disabled caching for the walkthrough so that each execution reads from S3 again.
We can inspect our quota usage by running the following query:
SELECT
quota_name,
profile_events['S3GetObject'] AS s3_get_requests,
max_profile_events['S3GetObject'] AS daily_limit
FROM system.quota_usage
WHERE quota_name = 'review_s3_budget';| quota_name | s3_get_requests | daily_limit |
|---|---|---|
| review_s3_budget | 21 | 30 |
Our query made 21 GET requests. If we run the query again, followed by the quota inspection query, we'll see the following:
| quota_name | s3_get_requests | daily_limit |
|---|---|---|
| review_s3_budget | 42 | 30 |
The second execution completes even though it takes our usage above the quota. ClickHouse checks this quota before executing a query, so exceeding it doesn’t interrupt a query already in progress. But, if we run the query for a third time, we'll see the following:
Code: 201. DB::Exception: Quota for user `review_analyst` for 86400s has been exceeded: S3GetObject = 42/30. Interval will end at 2026-11-28 00:00:00. Name of quota template: `review_s3_budget`. (QUOTA_EXCEEDED)Fewer requests when reading Iceberg tables
Contributed by Groene AI, Alexey Milovidov, and Konstantin Vedernikov
Reading an Iceberg table involves reading metadata as well as the data files themselves. Before ClickHouse 26.11, ClickHouse made a HEAD request for each manifest and data file to fetch object metadata before reading its contents. For tables with many files, those requests add up.
ClickHouse 26.11 no longer sends a separate HEAD request before reading each manifest or each Parquet or ORC data file in an Iceberg table. For the data files, it uses the file sizes already recorded in the Iceberg metadata.
Let's try this with the NYC taxi dataset. We loaded the trips from the June 2023 yellow taxi Parquet file into an Iceberg table backed by local MinIO storage. This resulted in 60 Parquet data files and 31 manifests.
The table contains the pickup location, pickup time, and fare amount. From a local ClickHouse session, we can connect to the existing Iceberg table using the IcebergS3 table engine:
CREATE TABLE taxis
ENGINE = IcebergS3(
'http://localhost:19080/warehouse/taxis',
'iceberg-demo',
'iceberg-demo-local-only',
'Parquet'
);ClickHouse reads the column names and types from the Iceberg metadata, so we don’t need to specify them in
CREATE TABLE.
Ok, now we're going to run some queries. We'll disable caching for the comparison so that each execution reads from object storage:
SET use_query_cache = 0,
use_query_condition_cache = 0,
use_columns_cache = 0,
enable_filesystem_cache = 0,
use_parquet_metadata_cache = 0,
use_iceberg_metadata_files_cache = 0,
iceberg_metadata_staleness_ms = 0;We can then calculate the number of trips and total fare by pickup location:
SELECT
pickup_location,
count() AS trips,
sum(fare_amount) AS total_fare
FROM taxis
GROUP BY pickup_location
ORDER BY pickup_location;We ran this query against the same Iceberg snapshot on ClickHouse 26.10.11.12 and 26.11.2.4, with max_threads = 12 and a 2 GiB query-memory limit. After one warm-up per version, we alternated three measured runs.
Running the CLI with --print-profile-events --profile-events-delay-ms -1 prints the profile-event totals for each query. The request counts were the same in all three measured runs:
| Profile event | 26.10 | 26.11 |
|---|---|---|
S3HeadObject | 96 | 5 |
S3GetObject | 96 | 96 |
S3ListObjects | 1 | 1 |
So with ClickHouse 26.11, we have 95% fewer HEAD requests. The 91 eliminated requests correspond to our 60 data files and 31 manifests. ClickHouse still reads the data and metadata contents, so the GET count remains unchanged.
You can also see the query time and peak memory, which were recorded with the CLI's --time and --memory-usage options:
| Version | Run | Query time | Peak memory |
|---|---|---|---|
| 26.10 | 1 | 215 ms | 27.18 MiB |
| 26.10 | 2 | 198 ms | 23.98 MiB |
| 26.10 | 3 | 174 ms | 25.38 MiB |
| 26.11 | 1 | 169 ms | 21.55 MiB |
| 26.11 | 2 | 223 ms | 20.74 MiB |
| 26.11 | 3 | 161 ms | 24.27 MiB |
Our median query time fell from 198 ms to 169 ms in this local test. We'd expect to see an even better improvement when running with more files or when accessing remote storage, where each avoided request saves a network round trip.
Get started today
Interested in seeing how ClickHouse works on your data? Get started with ClickHouse Cloud in minutes and receive $300 in free credits.
Sign up


