1. Home
  2. Knowledge Base
  3. ClickHouse DBA
  4. Compressing ClickHouse Database for Performance
  1. Home
  2. Knowledge Base
  3. ClickHouse Performance
  4. Compressing ClickHouse Database for Performance

Compressing ClickHouse Database for Performance

How to configure compression parameters in ClickHouse for Performance?


ClickHouse supports advanced compression to performance while reducing storage costs. Technically, Tuning the storage infrastructure of the ClickHouse schema will equally improve the performance of both memory and network bandwidth. ClickHouse supports both LZ4 and ZSTD. LZ4 is faster than ZSTD but it provides smaller compression ratio compared to ZSTD

You can implement ZSTD by adding the following lines to the config:

<compression incl="clickhouse_compression">
        <case>
                <method>zstd</method>  
        </case>
</compression>

LZ4 and ZSTD Compression Ratio

CompressionRatio
LZ43.5
ZSTD5.0

Benchmarking Performance

SELECT toYear(CAMP_PERF_DATE) AS CAMPCONV, sum(CAMP_CLICKS) FROM CAMPAIGN_TAB GROUP BY CAMPCONV;

Query performance results for LZ4 compression:

Cold run:

24 rows in set. Elapsed: 37.613 sec. Processed 11.59 billion rows, 81.37 GB (971.49 million rows/s., 7.15 GB/s.)

Hot run:

24 rows in set. Elapsed: 6.158 sec. Processed 11.59 billion rows, 81.37 GB (2.74 billion rows/s., 28.51 GB/s.)

Query performance results for ZSTD compression:

Cold run:

24 rows in set. Elapsed: 39.527 sec. Processed 11.59 billion rows, 81.37 GB (856.72 million rows/s., 6.29 GB/s.)

Hot run:

24 rows in set. Elapsed: 8.173 sec. Processed 11.59 billion rows, 81.37 GB (2.38 billion rows/s., 26.53 GB/s.)

Technically the performance numbers difference in cold runs is lean. But, During hot runs, LZ4 proved faster due to much fewer I/O operations and the decompression performance factors proved expensive.

Conclusion 

  • We strongly recommend ZSTD when there are I/O bottleneck in queries with huge range scans
  • When decompression latency is a concern, we recommend LZ4.
  • In ClickHouse you have an option to specify “none” compression, This is recommended for extreme performance SSD NVME arrays
Was this article helpful?

Related Articles

CHISTADATA IS COMMITTED TO OPEN SOURCE SOFTWARE AND BUILDING HIGH PERFORMANCE COLUMNSTORES

In the spirit of freedom, independence and innovation. ChistaDATA Corporation is not affiliated with ClickHouse Corporation 

Need Support?

Can't find the answer you're looking for?
Contact Support

ChistaDATA Inc. Knowledge base is licensed under the Apache License, Version 2.0 (the “License”)

Copyright 2022 ChistaDATA Inc

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.