ClickHouse Input format matchup: Which is fastest & most efficient

Tom Schreiber
26 min readbeginner
--
View Original

Overview

This article explores the various input formats supported by ClickHouse for data ingestion, focusing on performance and efficiency. It introduces the FastFormats benchmark, which evaluates the ingestion speed and hardware efficiency of these formats, providing insights on how to optimize data loading processes.

What You'll Learn

1

How to choose the most efficient input format for ClickHouse ingestion

2

Why batching data improves ingestion performance in ClickHouse

3

When to use compression for data transfer to ClickHouse

4

How to optimize ClickHouse inserts by pre-sorting data

Prerequisites & Requirements

  • Understanding of ClickHouse and its data ingestion processes

Key Questions Answered

What are the fastest and most efficient input formats for ClickHouse?
The Native format is identified as the fastest and most efficient input format for ClickHouse ingestion, providing high compression ratios and minimal server-side processing overhead. Other formats like ArrowStream and Parquet also perform well but are slower than Native.
How does compression affect ClickHouse data ingestion performance?
Compression, particularly using LZ4, reduces data size with minimal CPU overhead, improving transfer speed and ingestion time. ZSTD offers higher compression ratios but requires more CPU resources for compression and decompression.
What impact does pre-sorting have on data ingestion in ClickHouse?
Pre-sorting data before transmission can enhance compression efficiency and allow ClickHouse to skip the sorting step during ingestion, leading to faster processing times. However, the performance gain from pre-sorting is moderate.
What are the client-side tuning options for optimizing ClickHouse inserts?
Key client-side tuning options include batching data, pre-sorting before transmission, converting data to an efficient format, and using compression to reduce transfer size. These optimizations can significantly improve server-side ingestion efficiency.

Key Statistics & Figures

Ingestion time for Native format with LZ4 compression
131 seconds
This is the time taken to ingest a dataset of 2.55 GiB using the Native format with LZ4 compression.
Performance improvement of Native format over ArrowStream
10%
Native format ingestion is 10% faster than ArrowStream format for the same dataset.
Performance improvement of Native format over RowBinary
18%
Native format ingestion is 18% faster than RowBinary format for the same dataset.
Performance improvement of Native format over TSV
31%
Native format ingestion is 31% faster than TSV format for the same dataset.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Key Actionable Insights

1
Utilize the Native format for data ingestion in ClickHouse to maximize performance and efficiency.
The Native format is designed for high-performance and low-latency processing, making it the best choice for scenarios requiring quick data loading.
2
Implement data batching to reduce insert overhead and improve processing efficiency.
Batching allows ClickHouse to handle larger data volumes more efficiently, which is crucial for high-throughput applications.
3
Consider using LZ4 compression for data transfers to balance speed and resource usage.
LZ4 provides a good trade-off between compression efficiency and CPU overhead, making it suitable for scenarios where quick data ingestion is essential.
4
Evaluate the need for pre-sorting data based on the specific use case and data characteristics.
While pre-sorting can improve ingestion times, ClickHouse's internal sorting capabilities are highly efficient, so it may not always be necessary.

Common Pitfalls

1
Failing to pre-sort data before ingestion can lead to unnecessary processing overhead.
While ClickHouse can efficiently sort data, pre-sorting can save time and resources if the data is already nearly ordered. Clients should assess their data characteristics before deciding.

Related Concepts

Data Ingestion Strategies
Performance Optimization Techniques
Compression Methods In Data Transfer