How we made ClickHouse UPDATEs 1,000× faster (Part 3: Benchmarks)

Tom Schreiber
21 min readbeginner
--
View Original

Overview

This article discusses the significant performance improvements achieved in ClickHouse's SQL UPDATE operations, demonstrating how they can be up to 1,000× faster than traditional mutation methods through the use of lightweight patch-part updates. It provides detailed benchmarks comparing various update methods and their impact on query performance.

What You'll Learn

1

How to implement lightweight updates in ClickHouse for faster SQL operations

2

Why lightweight updates can be more efficient than classic mutations

3

When to choose between lightweight updates and classic mutations

4

How to benchmark different update methods in ClickHouse

Prerequisites & Requirements

  • Understanding of SQL and database operations
  • Familiarity with ClickHouse and its architecture(optional)

Key Questions Answered

How much faster are SQL UPDATEs in ClickHouse compared to classic mutations?
SQL UPDATEs in ClickHouse can be up to 1,700× faster than classic mutations for bulk updates and up to 2,400× faster for single-row updates. This significant speedup is achieved through the use of lightweight patch-part updates that avoid full column rewrites.
What are the different update methods available in ClickHouse?
ClickHouse offers several update methods including classic mutations, lightweight updates, and on-the-fly mutations. Each method has distinct performance characteristics, with lightweight updates providing the fastest visibility for changes with minimal query impact.
When should lightweight updates be used in ClickHouse?
Lightweight updates are best used for frequent, small changes, typically when updating less than 10% of a table. They provide almost instant visibility of changes while minimizing the worst-case query slowdowns until the updates are fully materialized.
What is the impact of different update methods on query performance?
The impact varies: classic mutations require full rewrites and can slow down queries significantly, while lightweight updates allow for faster visibility but may introduce some overhead if large patches are created. On-the-fly mutations provide instant visibility but can lead to higher query slowdowns if many updates stack up.

Key Statistics & Figures

Speedup of bulk SQL UPDATEs
1,700× faster
Compared to classic mutations
Speedup of single-row SQL UPDATEs
2,400× faster
Compared to classic mutations
Time for bulk standard SQL UPDATE
60 ms
Instead of 100 s with classic mutations

Technologies & Tools

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

Database
Clickhouse
Used for benchmarking and implementing SQL UPDATEs
Cloud Infrastructure
AWS EC2
Hosting environment for benchmarks

Key Actionable Insights

1
Utilize lightweight updates for frequent data corrections to enhance performance in ClickHouse.
Lightweight updates allow for quick, efficient modifications without the overhead of full rewrites, making them ideal for real-time applications where data accuracy is critical.
2
Benchmark different update methods to identify the best approach for your workload.
Understanding the performance characteristics of each update method can help optimize your database operations and ensure that you are using the most efficient technique for your specific use case.
3
Consider the size of updates when choosing between lightweight updates and classic mutations.
For small updates, lightweight methods are preferred, but for larger changes, classic mutations may be more efficient in the long run due to their lower impact on query performance once materialized.

Common Pitfalls

1
Overusing lightweight updates for large data changes can lead to performance issues.
While lightweight updates are efficient for small changes, they can create large patch parts that slow down queries until fully materialized. It's better to use classic mutations for larger updates.

Related Concepts

Benchmarking Database Performance
SQL Update Operations
Clickhouse Architecture And Design