Move schema and data from MariaDB to ClickHouse using the MySQL table engine, clickhouse-mysql, and INSERT…SELECT.
ClickHouse delivers sub-second analytics over billions of rows thanks to columnar storage and vectorized execution. Migrating workloads that are read-heavy, dashboard-centric, or aggregation-focused can slash query latency and hardware cost.
Prepare network connectivity between the MariaDB and ClickHouse hosts, ensure identical time zones, and grant SELECT rights on the MariaDB source. Install clickhouse-client and, optionally, the clickhouse-mysql
migration utility.
The ENGINE = MySQL
table acts as a live pointer to the MariaDB source, letting you read data without exporting files.
Define columns with optimal ClickHouse types—including UInt
, Decimal
, and DateTime
—and pick a primary key for the MergeTree engine.
Run a single INSERT INTO … SELECT *
to batch-load rows.Use SET max_insert_block_size
and max_threads
to tune throughput.
.
The clickhouse-mysql
tool scans MariaDB metadata, creates matching MergeTree tables, and streams data in parallel. Flags like --migrate-data
and --skip-sync
control behavior.
Schedule incremental jobs that insert only new or updated rows using WHERE updated_at > last_cutover
, or switch to Materialized Views that consume binlog-based Kafka streams.
Validate row counts after each load, cast ENUMs to LowCardinality(String), disable MariaDB triggers during export, and checkpoint replication lags before flipping traffic.
Yes. Use MySQL engine tables for an initial bulk load, then run incremental INSERTs based on an updated_at
column until cut-over.
No. Referential integrity must be enforced at the application layer or during ETL.
Up to several gigabytes, but optimal batches are 100–500 MB. Adjust max_insert_block_size
to balance memory and throughput.