Persisting Tables · Writing Partitioned Tables to Disk · Practice Question
Check Whether a Column Was Persisted with Compression
Question
After persisting the table to disk, how can you confirm whether or not compression was applied to a specific column?
Solution
-21! `:/hdb/2025.01.15/t/priceFor an uncompressed column, the result is empty.
Example output for a compressed column:
compressedLength | 2082
uncompressedLength| 2728
algorithm | 2i
logicalBlockSize | 17i
zipLevel | 6iExplanation
-21! is the kdb+ internal function for inspecting the compression metadata of an on-disk column file. It takes a file path symbol and, for a compressed file, returns a dictionary with five keys:
| Key | Meaning |
|---|---|
compressedLength | Size of the column file on disk in bytes |
uncompressedLength | Size of the data when loaded into memory |
algorithm | Compression algorithm: 1i=q IPC, 2i=gzip, 3i=snappy, 4i=lz4hc, 5i=zstd |
logicalBlockSize | The power-of-2 block size used during compression (17 = 2^17 = 128 KB) |
zipLevel | Compression effort, 1–9 (for gzip) |
If the result is empty, the file was written without compression — the default when no compression settings have been specified.
The function operates on any binary column file path — it does not require the database to be loaded or .Q.par to be used. You can check any column by supplying its full path directly:
-21! `:/hdb/2025.01.15/t/sym
-21! `:/hdb/2025.01.15/t/qtyThis is the standard first step when diagnosing storage footprint or verifying that a compression job ran correctly.