Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 9 min read How-to mediumAdept

Monitoring Asynchronous Inserts

ClickHouse asynchronous inserts can be monitored with SQL over system tables (query_log, asynchronous_insert_log, part_log, parts, and the PendingAsyncInsert metric), packaged as parameterized views for part creations, buffer flushes, flush errors and pending flushes. The flush-error view matters most in fire-and-forget mode, where failed buffer flushes are never reported back to the client. Worked scenarios show how flush and part frequency diverge from the configured threshold. Each node keeps a separate buffer per insert query shape and per settings set, and a partitioned table gets at least one part per partition key value in each flush.

Related posts

  • Essential Monitoring Queries - part 1 - INSERT Queries

    ClickHouse mediumAdept

    ClickHouse system tables such as part_log, query_log, asynchronous_insert_log, asynchronous_metric_log and parts can be queried with SQL to monitor and troubleshoot INSERT workloads. Ready-to-use queries cover new part creation rate, bulk insert counts versus rows written, insert duration percentiles, per-insert memory and CPU, MaxPartCountForPartition, parts per partition, and part-level errors. Comparing insert request counts to rows written, or watching part counts climb, gives early warning of small-insert patterns and high-cardinality partition keys that lead to 'Too many parts' errors. Duration and resource metrics are only accurate for synchronous inserts, not async_insert or the Buffer engine, and alerting on these queries through tools like Grafana is recommended.

  • Asynchronous Data Inserts in ClickHouse

    ClickHouse mediumAdept

    ClickHouse asynchronous inserts move batching from the client to the server. Insert data goes into in-memory buffers, one per query shape and settings on each node, and is flushed as larger parts, which avoids the 'Too many parts' error that frequent small synchronous inserts trigger. In a benchmark with a serverless uptime-monitoring app (UpClick), 200 cloud functions inserting every 10 seconds pushed a 3-node ClickHouse Cloud service to the 300-active-part limit within 5 minutes using synchronous inserts. The post then covers buffer flush semantics, deduplication for idempotent retries, errors that only surface at flush time, how asynchronous inserts compare to Buffer tables, and how to tune return behavior and flush settings.

  • ClickHouse v21.11 Released

    ClickHouse mediumAdept

    ClickHouse 21.11 adds asynchronous inserts, which buffer many small concurrent INSERTs server-side and flush them as a single batch. This removes the need for Kafka or buffer tables in high-rate ingestion, and it is tunable via async_insert, wait_for_async_insert, async_insert_threads, async_insert_max_data_size and async_insert_busy_timeout_ms. The release also brings an interactive clickhouse-local CLI that needs no server, executable UDFs written in any language, named predefined connections to external sources such as MySQL and S3, and automatic compression handling for INTO OUTFILE and FROM INFILE.

  • Building a Unified Data Platform with ClickHouse

    ClickHouse mediumAdept

    Synq, a data observability startup, consolidated its user-facing application, internal BI, in-app analytics and ML training data onto a single ClickHouse Cloud cluster after Postgres with a time-series plugin struggled with large backfills. Naive per-message inserts from its Go ingestion service caused part explosions and insert timeouts. Buffer tables fixed that but used too much cluster memory, so the team settled on Async Inserts and handled duplicates with ReplacingMergeTree plus LIMIT 1 BY on a surrogate key. Materialized views feeding query-specific tables with ORDER BY keys matched to access patterns cut scanned data by an order of magnitude and keep API latencies around 100ms, while dbt builds auditing and daily-aggregated analytics tables without separate ETL.

  • System Tables and a Window into the Internals of ClickHouse

    ClickHouse mediumAdept

    ClickHouse system tables are read-only virtual tables in the system database that expose server state, settings, metrics, errors, parts and query history. Most live in memory, while log tables such as query_log, part_log and metric_log persist on MergeTree storage. A set of practical diagnostic queries shows how to use them: system.settings for non-default values, query_log with normalizedQueryHash and ProfileEvents for slow, memory-heavy and failed queries, system.errors for frequent error codes with traces, and part_log to confirm inserts are producing parts. These queries can serve as a starting toolkit for troubleshooting and understanding cluster usage.

The quest for software engineering knowledge.

Look:
Layout: