---
title: "Five Methods For Database Obfuscation"
description: "ClickHouse needed publishable benchmark data that kept the properties driving analytical query performance in its private web analytics dataset: compression ratio, per-column and cross-column cardinality, and value distributions such as power laws."
url: "https://swe.quest/articles/five-methods-for-database-obfuscation-477824be1d934bc1"
canonical: "https://clickhouse.com/blog/five-methods-of-database-obfuscation"
source: "ClickHouse"
published: "2023-02-16"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 23
tags: ["analytics","privacy","performance","testing","algorithms"]
---

# Five Methods For Database Obfuscation

A post on [ClickHouse](https://swe.quest/sources/clickhouse.md), published 2023-02-16, 23 min read, Deep dive. Original: [https://clickhouse.com/blog/five-methods-of-database-obfuscation](https://clickhouse.com/blog/five-methods-of-database-obfuscation)

## Summary

ClickHouse needed publishable benchmark data that kept the properties driving analytical query performance in its private web analytics dataset: compression ratio, per-column and cross-column cardinality, and value distributions such as power laws. The post compares approaches to obfuscating that data. Hand-written probabilistic models in C++ were too laborious and specific to one dataset. An LSTM that generated TSV dumps produced gigabyte-sized models, ran at about 100 rows per second and distorted character frequencies. Mutating the literals inside LZ4-compressed data preserved compression ratio and decompression speed while removing every original byte, guided by heuristics that keep structure such as valid UTF-8.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Analytics & OLAP](https://swe.quest/tags/analytics.md) (Data & databases)
- [Privacy](https://swe.quest/tags/privacy.md) (Security)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [Algorithms](https://swe.quest/tags/algorithms.md) (Architecture & design)

## Prerequisites

- columnar analytical databases ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))
- data compression basics
- hash tables
- probability distributions

## Keywords

ClickHouse, LZ4, ZSTD, HyperLogLog, LSTM, Markov models, clickhouse-obfuscator

## Related posts

- [ClickHouse Newsletter November 2022: The purifying effects of obfuscation](https://swe.quest/articles/clickhouse-newsletter-november-2022-the-purifying-effects-of-obfuscation-ba5293e588a311a6.md): ClickHouse · 2022-11-10 · Medium · 8 min read · Analytics & OLAP, Testing, Privacy, Databases
  ClickHouse Cloud pricing now charges only for compute and storage, and ClickHouse 22.10 adds S3 backups (full and incremental), \`SET setting = DEFAULT\`, forced merging of old parts via \`min\_age\_to\_force\_merge\_seconds\`, a relaxed too-many-parts check for large partitions, new random-distribution functions and a preview Kafka Connect sink with exactly-once semantics.
- [Compressing nginx logs 170x with column storage](https://swe.quest/articles/compressing-nginx-logs-170x-with-column-storage-f7055f56d674ca49.md): ClickHouse · 2025-10-23 · Medium · 14 min read · Analytics & OLAP, Observability, Storage engines, Cost optimization
  Parsing nginx access logs into typed columns in ClickHouse and tuning storage raises compression from roughly 38x (ZSTD on the raw file) to about 178x on a 66.7M-line, 20 GB dataset.
- [Speeding up LZ4 in ClickHouse](https://swe.quest/articles/speeding-up-lz4-in-clickhouse-dbbd26281ee7c0df.md): ClickHouse · 2023-04-12 · Hard · 32 min read · Performance engineering, Storage engines, C & C++, Algorithms, Analytics & OLAP
  LZ4 decompression often tops ClickHouse query profiles because highly compressible, cached columnar data shifts the cost onto CPU, yet storing data uncompressed proved impractical due to disk space.
- [Improve logs compression with log clustering](https://swe.quest/articles/improve-logs-compression-with-log-clustering-6656d2f1ad6f9ec5.md): ClickHouse · 2025-10-30 · Medium · 16 min read · Observability, Analytics & OLAP, Data pipelines, Algorithms
  Drain3 log template mining, run inside ClickHouse as a Python executable UDF, can turn unstructured application logs into structured columnar data.
- [Optimizing ClickHouse with Schemas and Codecs](https://swe.quest/articles/optimizing-clickhouse-with-schemas-and-codecs-795411feff5942b1.md): ClickHouse · 2022-12-14 · Medium · 23 min read · Analytics & OLAP, Storage engines, Performance engineering, SQL
  Tightening a ClickHouse schema with strict types cuts a 1B-row NOAA weather dataset from 131.58 GiB to 71.38 GiB uncompressed.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
