From 2bd11cb7ad362c6c2bb3df954e5995de94964bc3 Mon Sep 17 00:00:00 2001 From: Bilal Godil Date: Wed, 18 Mar 2026 14:07:26 -0700 Subject: [PATCH] clickhouse improve sync speed --- apps/backend/src/lib/external-db-sync.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/backend/src/lib/external-db-sync.ts b/apps/backend/src/lib/external-db-sync.ts index 885952530..d2f25202b 100644 --- a/apps/backend/src/lib/external-db-sync.ts +++ b/apps/backend/src/lib/external-db-sync.ts @@ -1433,7 +1433,9 @@ async function syncClickhouseMapping( } const clickhouseTableName = `analytics_internal.${mapping.targetTable}`; - await ensureClickhouseSchema(client, tableSchema, clickhouseTableName); + // Skip ensureClickhouseSchema — we only sync to our own internal ClickHouse + // where tables are already created. CREATE TABLE IF NOT EXISTS is always a + // no-op but costs a slow DDL round trip per mapping per sync invocation. let lastSequenceId = await getClickhouseLastSyncedSequenceId(client, tenancyId, mappingId);