You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
clientModule: the client (client-v2; with legacy: the v1 client)connectivityArea: connection, TLS, pool, timeouts, cancellation, transport, compressionenhancementjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)performance
Hello, to second that, out of curiosity, I tried to use http compression for insertion, and I noticed a huge decrease in performance, like 100 x slower that internal lz4 compression.
I ran a quick test to compare the compressor and check if I was imagining things or not.
Here are the test and the results:
public void insertFormatOutputStreamBench() throws Exception {
Instant instant = Instant.parse("2025-01-23T22:00:35.00Z");
Supplier<Stream<Object[]>> rows = () -> IntStream.range(0, 300).boxed()
.flatMap(c1 -> IntStream.range(0, 300).boxed()
.flatMap(c2 -> IntStream.range(0, 3).boxed()
.map(c3 -> {
long value = c1 + c2 + c3;
return new Object[]{instant, "k1_v" + c1, "k2_v" + c2, "k3_v" + c3, value, value + 1, value + 2, value + 3};
})));
bench("FramedLZ4CompressorOutputStream", rows, out -> {
try {
return new FramedLZ4CompressorOutputStream(out);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
bench("LZ4FrameOutputStream", rows, out -> {
try {
return new LZ4FrameOutputStream(out);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
bench("ClickHouseLZ4OutputStream,", rows, out -> new ClickHouseLZ4OutputStream(out, LZ4Factory.fastestInstance().fastCompressor(), 65536));
}
private void bench(String name, Supplier<Stream<Object[]>> rows, UnaryOperator<OutputStream> writer) throws IOException {
ByteArrayOutputStream target = new ByteArrayOutputStream();
Stopwatch timer = Stopwatch.createStarted();
try (OutputStream outputStream = writer.apply(target)) {
rows.get().forEach(row -> {
try {
BinaryStreamUtils.writeDateTime(outputStream, LocalDateTime.ofInstant((Instant) row[0], ZoneOffset.UTC), TimeZone.getTimeZone("UTC"));
BinaryStreamUtils.writeString(outputStream, (String) row[1]);
BinaryStreamUtils.writeString(outputStream, (String) row[2]);
BinaryStreamUtils.writeString(outputStream, (String) row[3]);
BinaryStreamUtils.writeUnsignedInt64(outputStream, (Long) row[4]);
BinaryStreamUtils.writeUnsignedInt64(outputStream, (Long) row[5]);
BinaryStreamUtils.writeUnsignedInt64(outputStream, (Long) row[6]);
BinaryStreamUtils.writeUnsignedInt64(outputStream, (Long) row[7]);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
}
System.out.printf("%s took %d ms, produced %d bytes %n", name,
timer.elapsed(TimeUnit.MILLISECONDS), target.size());
}
FramedLZ4CompressorOutputStream took 17687 ms, produced 1844286 bytes
LZ4FrameOutputStream took 189 ms, produced 2702992 bytes
ClickHouseLZ4OutputStream, took 117 ms, produced 2576610 bytes
In this state, it seems that FramedLZ4CompressorOutputStream is not really usable for insertion
@mzitnik@simondaudin
This is because HTTP compressed is backed by Apache Compress that uses LZ77 own implementation instead of lz4-java with JNI support.
Insert will be fixed. Query need more code changes because lz4-java doesn't support dependent blocks in current version (or I'm doing something wrong)
clientModule: the client (client-v2; with legacy: the v1 client)connectivityArea: connection, TLS, pool, timeouts, cancellation, transport, compressionenhancementjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)performance
Activity
simondaudin commentedon Mar 24, 2026
Hello, to second that, out of curiosity, I tried to use http compression for insertion, and I noticed a huge decrease in performance, like 100 x slower that internal lz4 compression.
I ran a quick test to compare the compressor and check if I was imagining things or not.
Here are the test and the results:
In this state, it seems that
FramedLZ4CompressorOutputStreamis not really usable for insertionchernser commentedon Oct 1, 2026
@mzitnik @simondaudin
This is because HTTP compressed is backed by Apache Compress that uses LZ77 own implementation instead of lz4-java with JNI support.
Insert will be fixed. Query need more code changes because lz4-java doesn't support dependent blocks in current version (or I'm doing something wrong)