Summary
internal/clickhouse/clickhouse.go constructs the clickhouse.Options{} without setting Compression. With this field unset, clickhouse-go v2 sends rows over the native protocol uncompressed.
For row data that's largely text/JSON (events, deliveries), enabling LZ4 typically gives a 3–5× wire-size reduction at negligible CPU cost — the standard recommendation from the clickhouse-go maintainers.
Proposed change
opts := &clickhouse.Options{
Addr: []string{config.Addr},
Auth: clickhouse.Auth{...},
DialTimeout: 10 * time.Second,
ReadTimeout: 30 * time.Second,
Compression: &clickhouse.Compression{
Method: clickhouse.CompressionLZ4,
},
}
Optional: gate by a CLICKHOUSE_COMPRESSION env (none / lz4 / zstd) so it can be tuned or disabled per deployment without a rebuild.
Why LZ4
- LZ4 is the standard pick for the CH native protocol — fast compress/decompress, low CPU, decent ratio.
- ZSTD gets better ratio at higher CPU; worth as an opt-in for high-row-size workloads.
- Brotli/GZIP exist in the driver but are usually outperformed by LZ4 on this kind of payload.
Acceptance
clickhouse.Options.Compression is set (default LZ4) in internal/clickhouse/clickhouse.go.
- Optional env knob to override / disable.
- Verified inserts and reads both succeed against ClickHouse Cloud and a local CH instance.
Summary
internal/clickhouse/clickhouse.goconstructs theclickhouse.Options{}without settingCompression. With this field unset, clickhouse-go v2 sends rows over the native protocol uncompressed.For row data that's largely text/JSON (events, deliveries), enabling LZ4 typically gives a 3–5× wire-size reduction at negligible CPU cost — the standard recommendation from the clickhouse-go maintainers.
Proposed change
Optional: gate by a
CLICKHOUSE_COMPRESSIONenv (none/lz4/zstd) so it can be tuned or disabled per deployment without a rebuild.Why LZ4
Acceptance
clickhouse.Options.Compressionis set (default LZ4) ininternal/clickhouse/clickhouse.go.