Supercharging your large ClickHouse data loads - Part 1: Performance and resource usage factors
ClickHouse ingest performance and resource usage for large loads into MergeTree tables are governed by three factors: insert block size, insert parallelism, and hardware size. Larger insert blocks use more memory but produce fewer initial parts and so fewer background merges. Block size is controlled by min_insert_block_size_rows/bytes when the server pulls data, and by max_insert_block_size when clients push data or async inserts are used. Parallelism comes from max_insert_threads, s3/url glob reads, cluster table functions like s3Cluster, and parallel clients, while more CPU and RAM raise part size limits, parallelism and merge throughput.
Related posts
- Supercharging your large ClickHouse data loads - Part 2: Tuning a large data load for speed
ClickHouse mediumAdept
Tuning insert block size and insert parallelism lets a 65-billion-row (~14 TiB raw) PyPI load into ClickHouse run almost 3x faster than with default settings on the same hardware. On servers with 59 cores and 236 GiB RAM, the sweet spot was 32 insert threads with 10-million-row blocks. Larger blocks exhaust memory at higher thread counts, while using all cores for inserts starves background merges. A rule of thumb follows: set max_insert_threads to about half the cores, and set min_insert_block_size_bytes to target peak memory / (~3 × threads). With SharedMergeTree in ClickHouse Cloud, ingest throughput scales linearly as servers are added.
- ClickHouse Newsletter October 2022: A cloud has arrived
ClickHouse mediumAdept
ClickHouse Cloud entered public beta, storing data on shared object storage reachable by all nodes, so users no longer configure replication, sharding or rebalancing, and storage costs less than on block storage. Version 22.9 adds an experimental `annoy` ANN vector index, a KeeperMap table engine, `insert_quorum = auto`, INTERSECT/EXCEPT DISTINCT and an official TypeScript Node.js client. The query-of-the-month section shows that more threads can hurt. An S3 insert with `max_threads = 100` exhausts memory, while 4 threads beat autodetection by 33%. Under concurrent load, `max_threads = 1` tripled throughput from 3.8 to 13.1 QPS.
- Getting started with ClickHouse? 13 mistakes and how to avoid them
ClickHouse mediumAdept
ClickHouse's most common beginner mistakes mostly come from misunderstanding parts and merges. A high-cardinality partition key (keep it under 1,000 values), many small inserts, and too many materialized views all lead to "Too many parts" errors. The fixes are to batch 10,000 to 100,000 rows per insert or use async inserts with wait_for_async_insert=1, and to scale vertically before adding nodes. Other guidance covers classic ALTER mutations versus lightweight updates via patch parts (up to 1,000× faster), deduplication with ReplacingMergeTree and FINAL, lightweight deletes, the native JSON type versus explicit columns, avoiding Nullable, and insert-time deduplication.
- Supercharging your large ClickHouse data loads - Part 3: Making a large data load resilient
ClickHouse mediumAdept
Multi-day loads of billions to trillions of rows into ClickHouse can survive transient failures by splitting the input into retryable tasks. ClickPipes covers managed ingestion from Kafka. For other sources, the open ClickLoad script loads Parquet files from object storage. Stateless workers claim file-chunk tasks from a KeeperMap-backed table and insert each chunk into a per-worker staging table via INSERT INTO SELECT. On failure they truncate and retry; on success they move partitions to the target table, giving exactly-once storage without costly mutations or deduplication. The design scales roughly linearly with workers and servers (3→6 servers doubled throughput from 4M to 8M rows/s on a 600B-row load), works with any partition key, and also covers projections and materialized views through cloned staging tables.
- Top 10 best practices tips for ClickHouse
ClickHouse mediumAdept
Ten practices for getting performance and storage efficiency out of ClickHouse, each measured on a 150M-row Amazon reviews dataset. Aligning ORDER BY with query filters (low-cardinality columns first) made one query 3x faster and cut scanned data 347x. Right-sized types, no Nullable and LowCardinality(String) doubled query speed and shrank storage. Partitioning is best avoided except for TTL expiry or FINAL on merge engines; monthly partitions slowed one aggregation 46x. The post also covers lightweight versus heavyweight skipping indexes, JSON type hints (38% less storage, 26% faster), and preferring Parquet/ORC for bulk ingestion.