Using MSSQL source to Clickhouse destination, ther...
# ask-ai
j
Using MSSQL source to Clickhouse destination, there is a specific big table for which every row seems to be inserted 1 by 1 instead of batched. This makes for a very slow replication. I can see megabytes of such logs on each run:
Copy code
pool-2-thread-1 i.a.c.l.d.a.AggregateStore(removeNextComplete):56 PUBLISH — Reason: Cardinality
2025-11-20 17:58:15 destination INFO DefaultDispatcher-worker-1 i.a.i.d.c.w.l.BinaryRowInsertBuffer(flush):70 Finished insert of 1 rows into datacache_AdInsertion
2025-11-20 17:58:15 destination INFO DefaultDispatcher-worker-1 i.a.i.d.c.w.l.BinaryRowInsertBuffer(flush):59 Beginning insert into datacache_AdInsertion
Why does the connection commit the batch every row and how can I improve this behaviour ? @kapa.ai
k
For the new ClickHouse v2 destination, inserts are normally batched; it uses an internal buffering layer and bulk/binary inserts rather than truly row‑by‑row writes. [[ClickHouse v2 docs](https://docs.airbyte.com/integrations/destinations/clickhouse)] However, the exact flushing/commit behavior (e.g. why you’re seeing
Finished insert of 1 rows
) and how to tune it is not documented in the available knowledge sources. The docs and issues mention: - The old ClickHouse destination (v1) is explicitly called out as potentially problematic for large datasets and performance, and has been replaced by the new Bulk‑CDK‑based destination. [[ClickHouse archived](https://docs.airbyte.com/integrations/destinations/clickhouse-deprecated); [ClickHouse v2 docs](https://docs.airbyte.com/integrations/destinations/clickhouse)] - There is an open epic to make warehouse destinations (including ClickHouse and MSSQL) scale better via buffering/batching, but it does not expose specific user‑tunable knobs, nor does it describe per‑row flush behavior. [[Scaling warehouse destinations](https://github.com/airbytehq/airbyte/issues/10260)] - There is a general design issue stating that batching should ideally be based on bytes rather than record count to avoid OOM and inefficient batching, but again it’s about internal design, not user configuration. [[Batch by bytes](https://github.com/airbytehq/airbyte/issues/3439)] Given that, the knowledge sources do not explain: - Why your particular stream is flushing after every record (e.g. “Reason: Cardinality”), - Nor how to configure batch size / buffer thresholds for the ClickHouse v2 destination. So based strictly on available information, I can only suggest: 1. Confirm you’re on the new ClickHouse v2 connector. If you’re still on the archived v1 connector, upgrade to the new ClickHouse destination, which is explicitly designed for bulk/batched loading and large datasets. [[ClickHouse archived](https://docs.airbyte.com/integrations/destinations/clickhouse-deprecated); [ClickHouse v2 docs](https://docs.airbyte.com/integrations/destinations/clickhouse)] 2. Open a GitHub issue with logs and details. Since batching behavior and “Reason: Cardinality” are not documented, the ClickHouse destination team would need to inspect this. There is a general epic about improving buffering across destinations, but your “1 row per flush” pattern for a single large table is not addressed there. [[Scaling warehouse destinations](https://github.com/airbytehq/airbyte/issues/10260)] 3. Check general platform guidance for destinations. Certified destinations must checkpoint at least every 15 minutes and handle idempotent re‑runs, which can influence how often they finalize batches and emit state, but the docs do not map this to per‑row flush behavior or expose tuning parameters. [[Partner destinations requirements](https://docs.airbyte.com/platform/connector-development/partner-certified-destinations#functional-requirements-of-certified-destinations)] Because the docs and issues don’t describe any user‑visible configuration for ClickHouse batch size or why a specific stream would flush per row, I can’t provide a concrete knob to change or a guaranteed workaround from the current knowledge sources.
Based on the information in the knowledge sources, the ClickHouse destination connector (version 2.x, built on the Bulk CDK) is designed to use batch inserts for improved performance, not row-by-row inserts. However, your logs indicate that each row is being inserted individually, which is highly inefficient and not the intended behavior for large tables. Possible reasons for this behavior: 1. Batching Logic Triggered by Cardinality or Buffer Size: The log line
PUBLISH — Reason: Cardinality
suggests that the batching mechanism is being triggered for every single row, possibly due to a configuration or logic that causes the buffer to flush after each record. This could be due to: - The batch size being set to 1 (either by default or due to a misconfiguration). - The buffer reaching a limit (such as memory or row size) after every row, which is unlikely unless the rows are extremely large. - Some property of the data (e.g., high cardinality or unique values) causing the buffer to flush after each insert. 2. Connector or Configuration Issue: There may be a bug or a specific configuration in your Airbyte setup or ClickHouse destination connector that is causing this behavior. The new ClickHouse connector is supposed to batch inserts for performance, as described in the documentation: > "The new architecture uses ClickHouse's native binary protocol and batch inserts for faster data loading." [ClickHouse destination documentation](https://docs.airbyte.com/integrations/destinations/clickhouse) 3. Known Issues and Buffering: There are ongoing discussions and issues in the Airbyte community about improving buffering and batching in destination connectors, including ClickHouse, to avoid performance bottlenecks and out-of-memory errors. The need for batching on bytes (not just record count) is also highlighted as a best practice for large or wide tables, but it is not clear if this is fully implemented in all connectors yet [EPIC: scale warehouse destination connectors](https://github.com/airbytehq/airbyte/issues/10260), [Batch on bytes read](https://github.com/airbytehq/airbyte/issues/3439). What you can do: - Check Connector Version: Ensure you are using the latest ClickHouse destination connector (v2.x), as the legacy version does not support efficient batching and is not recommended for large datasets [ClickHouse destination documentation](https://docs.airbyte.com/integrations/destinations/clickhouse). - Review Configuration: Look for any configuration options related to batch size or buffer limits in your Airbyte connection or the ClickHouse destination settings. If batch size is set to 1, increase it to a higher value. - Monitor Row Size: If your rows are extremely large, the buffer may be flushing after each row due to memory constraints. Consider reducing the row size if possible, or increasing the memory allocated to the Airbyte worker. - Check for Known Issues: If you are on the latest version and still experiencing this issue, it may be a bug or a limitation in the current implementation. You can check for open issues or report your findings to the Airbyte team for further investigation. Summary: The ClickHouse destination should batch inserts for performance, but your logs indicate it is not. This is likely due to configuration, data characteristics, or a connector issue. Review your batch size settings, ensure you are on the latest connector version, and consider reporting this behavior if it persists. If you need more specific guidance, please provide your connector version and any relevant configuration details.
j
FYI this was fixed by upgrading the connector to 2.1.14