A system.columns query on play.clickhouse.com and its output for four columns of github_events

I ran one query on a public ClickHouse server, and it told me where 4.97 TiB of data went.

The prompt was a Show HN this week. misa77 is a compressor that accepts slower compression in exchange for fast decoding. On the Silesia corpus in its README, misa77 -3 decodes at 5,909 MB/s, lz4 1.11.0 at 2,551 MB/s and zstd 1.5.7 -1 at 905 MB/s. The price shows up on the other side: level 6 compresses at 1.79 MB/s. The README puts it plainly: misa77 levels with LZ4 and zstd-class ratios "decode roughly 2 times faster than their counterparts."

That tradeoff is familiar to anyone who works on column stores. Data is written once and read many times, so the read side usually wins. I wanted to see what compression looks like on a real table, so I picked the one everyone can query.

The query

play.clickhouse.com is a public ClickHouse server with no sign-up. It has a github_events table. Every column reports its own sizes in system.columns:

SELECT count() AS columns, formatReadableSize(sum(data_uncompressed_bytes)) AS raw, formatReadableSize(sum(data_compressed_bytes)) AS on_disk, round(sum(data_uncompressed_bytes) / sum(data_compressed_bytes)) AS ratio FROM system.columns WHERE database = 'default' AND table = 'github_events' 
54 4.97 TiB 423.07 GiB 12 

SELECT count() FROM github_events returned 11,205,050,256 rows when I re-ran it. So 11.2 billion events, 54 columns, about 12x smaller on disk.

The columns are the interesting part

Drop the sum() and sort by raw size:

SELECT name, formatReadableSize(data_uncompressed_bytes) AS raw, formatReadableSize(data_compressed_bytes) AS on_disk, round(data_uncompressed_bytes / data_compressed_bytes, 1) AS ratio FROM system.columns WHERE database = 'default' AND table = 'github_events' ORDER BY data_uncompressed_bytes DESC LIMIT 12 
column raw on disk ratio
body 2.80 TiB 233.03 GiB 12.3
diff_hunk 315.94 GiB 24.79 GiB 12.7
title 145.58 GiB 13.79 GiB 10.6
base_sha 123.36 GiB 8.34 GiB 14.8
head_sha 123.36 GiB 14.76 GiB 8.4
labels 85.71 GiB 907.93 MiB 96.7
assignees 84.06 GiB 401.11 MiB 214.6
requested_reviewers 84.04 GiB 314.61 MiB 273.5
requested_teams 83.53 GiB 80.02 MiB 1068.9
merge_commit_sha 63.14 GiB 7.04 GiB 9
repo_name 51.00 GiB 14.73 GiB 3.5
commit_id 49.08 GiB 1.63 GiB 30.1

Three things stood out to me.

Empty arrays nearly vanish. requested_teams shrinks over 1,000x. SELECT round(avg(empty(requested_teams)) * 100, 2) FROM github_events returns 99.85: almost every row holds the same empty value, and repeated values are what compression feeds on.

Free text still gets 12x. body is more than half the raw table, and it compresses about as well as the table overall.

Two hashes of the same size behave differently. base_sha gets 14.8x and head_sha gets 8.4x, with identical raw sizes. My guess is that many pull requests share a base commit, so the values repeat. I haven't tested that yet, so treat it as a hunch.

What I couldn't check

The play user can't read the settings that would say which default codec the server uses, and these columns declare no codec of their own. So I can show the ratios, not the codec behind them. On your own server, the same system.columns query works, and the compression_codec column shows any per-column codec you've set.

Which column in your tables compresses worst, and do you know why?