> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hightouch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ClickHouse

> Connect ClickHouse as a source to sync your analytics data to any Hightouch destination.

> [!NOTE]
>
> Hightouch supports ClickHouse v20 and newer for the Basic sync engine. The
> [Lightning sync engine](#choose-your-sync-engine) requires ClickHouse v25 or
> newer.

## Overview

Hightouch lets you pull data stored in [ClickHouse](https://clickhouse.com/) and push it to downstream destinations. Most of the setup occurs in the Hightouch UI, but you need access to ClickHouse for information like your host, port, database name, and credentials.

> [!NOTE]
>
> You may need to allowlist Hightouch's IP addresses to let our systems connect to your warehouse. Reference our [networking docs](https://docs.hightouch.com/security/networking#ip-addresses) to determine which IP addresses you need to allowlist.

## Connection configuration

To get started, go to the [**Sources** overview page](https://app.hightouch.com/sources?from=docs) and click the **Add source** button. Select **ClickHouse** and follow the steps below.

### Choose authentication method

You can select to use either a **password** or **connection string**. A **connection string** is useful if you need to pass additional configuration options.

Hightouch connects to ClickHouse over the HTTP API using the [`@clickhouse/client`](https://github.com/ClickHouse/clickhouse-js) driver. Sources created before June 2026 use the legacy [ClickHouse JDBC driver](https://github.com/ClickHouse/clickhouse-java/tree/main/clickhouse-jdbc); Hightouch automatically routes those sources to the JDBC transport. The [Lightning sync engine](#choose-your-sync-engine) requires the new HTTP transport and is therefore only available for new sources or sources re-created after this transition.

If you select **connection string**, enter the connection string and skip to the [connection test section](#test-your-connection) of this page.

### Choose connection type

Hightouch can connect directly to ClickHouse over the public internet or via an SSH tunnel. Since data is encrypted in transit via TLS, a direct connection is suitable for most use cases. You may need to set up a tunnel if your ClickHouse instance is on a private network or virtual private cloud (VPC).

![Direct connection vs. SSH tunnel](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/get-started/connection-types-comparison.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=2300535707894b1f08608939cac812b2)

Hightouch supports both standard and reverse SSH tunnels. To learn more about SSH tunneling, refer to Hightouch's [tunneling documentation](https://docs.hightouch.com/security/ssh-tunneling.md).

### Configure your source

Enter the following required fields into Hightouch:

* **Host**: The hostname or IP address of your ClickHouse server.
* **Port**: The port number of your ClickHouse server's HTTP API. The default is 8123, but yours may be different.
* **Database**: The name of the database to use when Hightouch executes queries in ClickHouse.
* **Username**: This can be your personal ClickHouse login or a dedicated user for Hightouch.
* (Optional) **Password**: The password for the user specified above.

### Choose your sync engine

For optimal performance, Hightouch [tracks incremental changes](https://docs.hightouch.com/getting-started/concepts.md#change-data-capture) in your data model—such as added, changed, or removed rows—and only syncs those records. You can choose between two different sync engines for this work.

The **Basic engine** requires read-only access to ClickHouse. Hightouch executes a query in your database, reads all query results, and then determines incremental changes using Hightouch's infrastructure. This engine is easier to set up since it requires read—not write—access to ClickHouse.

The **Lightning engine** requires read and write access to ClickHouse. The engine stores previously synced data in a separate schema in ClickHouse managed by Hightouch. In other words, the engine uses ClickHouse to track incremental changes to your data rather than performing these calculations in Hightouch. Therefore, these computations are completed more quickly.

![Standard vs Lightning engine comparison](https://mintcdn.com/hightouch-3c037897/L_vQfA0JQEpeGUUo/images/get-started/sync-engine-comparison.png?fit=max\&auto=format\&n=L_vQfA0JQEpeGUUo\&q=85\&s=1202b36c58e475d85344db87dde2c825)

> [!TIP]
>
> Hightouch recommends using the Lightning sync engine when syncing more than 100,000 rows of data.

If you select the Basic engine, you can switch to the Lightning engine later. Once you've configured the Lightning engine, you can't move back to the Basic engine without recreating ClickHouse as a source.

To learn more, including migration steps and tips, check out the [Lightning sync engine docs](https://docs.hightouch.com/syncs/lightning-sync-engine.md).

#### Basic versus Lightning engine comparison

| Criteria | Basic sync engine | Lightning sync engine |
| - | - | - |
| Performance | Slower | Quicker |
| Ideal for large data models (over 100 thousand rows) | No | Yes |
| Reliability | Normal | High |
| Resilience to sync interruptions | Normal | High |
| Extra features | None | Warehouse Sync Logs, Match Booster, Identity Resolution |
| Ease of setup | Simpler | More involved |
| Location of change data capture | Hightouch infrastructure | ClickHouse schemas managed by Hightouch |
| Required permissions in ClickHouse | Read-only | Read and write |
| Ability to switch | You can move to the Lightning engine at any time | You can't move to the Basic engine once Lightning is configured |

#### Lightning engine setup

To set up the Lightning engine, you need to grant Hightouch write access to ClickHouse and create the databases Hightouch uses for [change data capture](https://docs.hightouch.com/syncs/lightning-sync-engine.md#warehouse-schemas) and [Warehouse Sync Logs](https://docs.hightouch.com/syncs/warehouse-sync-logs.md).

ClickHouse calls schemas "databases," so the planner and audit schemas are databases:

```sql theme={null}
CREATE DATABASE IF NOT EXISTS hightouch_planner;
CREATE DATABASE IF NOT EXISTS hightouch_audit;
GRANT CREATE TABLE, DROP TABLE, INSERT, SELECT, ALTER, OPTIMIZE
  ON hightouch_planner.* TO hightouch_user;
GRANT CREATE TABLE, DROP TABLE, INSERT, SELECT, ALTER, OPTIMIZE
  ON hightouch_audit.* TO hightouch_user;
```

The Lightning engine relies on lightweight `UPDATE`, lightweight `DELETE`, and the `_block_number` / `_block_offset` MergeTree columns, all of which require ClickHouse v25 or newer.

> [!NOTE]
>
> The Lightning engine isn't available on sources running the legacy JDBC
> transport. If you have an existing ClickHouse source and want to use
> Lightning, re-create the source so Hightouch connects through the new HTTP
> transport.

## Test your connection

When setting up ClickHouse as a source for the first time, Hightouch checks that you have the correct permissions. Once the test passes, click **Continue** to finish setup.

## Create models

Once your source configuration has passed the necessary validation, your source setup is complete. Next, you can set up [models](https://docs.hightouch.com/getting-started/concepts.md#models) to define which data you want to pull from ClickHouse.

The ClickHouse source supports writing queries in [the SQL editor](https://docs.hightouch.com/models/sql-editor.md) as its modeling method.

## Tips and troubleshooting

If you run into an issue this page doesn't cover, [contact support](#pylon-chat).

### Table selector fails to populate

If the [table selector](https://docs.hightouch.com/models/table-selector.md) fails to populate, it may be that the ClickHouse user
configured for the connection lacks necessary privileges. In order for Hightouch to automatically inspect the
schema and populate the table selector, the user configured for the connection must have `SELECT` permissions
on `INFORMATION_SCHEMA.COLUMNS`.
