Liquid Clustering "wins three of four workloads", but only three were measured

Contents
Should a big table be partitioned by date, Z-ordered, or switched to Liquid Clustering? A benchmark by Kushal Kumar Vishwakarma, republished by InfoQ China on 24 October, runs all three against the same data and four kinds of query.1 It’s worth a read for any Databricks team, as long as you check the numbers row by row.
Same 50 million rows, three ways to lay them out
The data is about 50 million synthetic retail transactions. The partitioned table splits on txn_date; ZOrder and Liquid Clustering share three keys, customer_id, region and txn_date. Each query ran five times with caching off, and the figures are medians of time and bytes read.2 ZOrder weakens with every extra key;4 Liquid Clustering runs OPTIMIZE incrementally and lets you change keys later.3
Three query types, three different winners
- One customer (W1): Liquid Clustering takes 1.003 s, 49% faster than partitioning. ZOrder reads the least yet is 0.4 s slower, so fewer bytes isn’t the same as faster.2
- One month (W2): with the date third in the ZOrder key, ZOrder is 78% slower than plain date partitioning.1 If the date isn’t first in your own ZOrder key, test your range queries first. Liquid Clustering reads as much as the partitioned table and is still about 37% faster.2
- Three-column filter (W3): Liquid Clustering’s one loss, nearly 5x slower and about 10x more data.1 Partitioning lands just 7 ms behind ZOrder, so the lesson is to avoid Liquid Clustering for this shape of query.2
The fourth workload, a full scan, repeats the second one’s numbers
The article’s fourth workload is a full-table SUM grouped by region, and it reports Liquid Clustering fastest (659 ms), ZOrder slowest (1.845 s) and partitioning in between (1.038 s).1 Those latencies and bytes read are identical, figure for figure, to W2’s one-month query, and already were in the first Medium version from 15 July.5 Neither the article nor the code shows W4 being run on its own, so it can’t serve as a comparison for now.2
Three layouts in one table
Databricks also recommends Liquid Clustering for new tables.3 The real answer is in your own query history, in four steps:
- Group your queries by the columns they filter on and pick the three most frequent groups.
- Take a sample that keeps your real hot spots and skew, and build one table per layout.
- Run each query five times with caching off, take the median, and record both latency and bytes read from the query profile. The author’s code is on GitHub, ready to adapt.2
- Add the two things the article skipped: a full-scan aggregation, and the compute it takes to keep each layout in shape after every day’s writes.
References
- 何时应使用 Liquid Clustering?湖仓布局策略基准测试, InfoQ China
- When Should You Use Liquid Clustering? A Practitioner's Benchmark of Lakehouse Layout Strategies (write-up and code), GitHub · kushalvishwak
- Use liquid clustering for tables, Databricks Documentation
- Data skipping, Databricks Documentation
- A Practitioner's Benchmark of Lakehouse Layout Strategies, Towards Data Engineering · Medium
Comments
Anonymous comments appear after review; signed in with GitHub, X or Facebook, they appear at once. Your email stays private and is only used for reply alerts.
Comments couldn’t load. Try again later.