ClickHouse
DocsDatabasesClickHouse

ClickHouse

Managed ClickHouse on StackBlaze: a fast columnar OLAP database with single-node or replicated high-availability deployments.

Adding ClickHouse from the Databases catalog and attaching it to the app injects CLICKHOUSE_URL and CLICKHOUSE_DB.

Creating a ClickHouse instance

From the project canvas, click + Service DatabasesClickHouse. Stage the add-on, then click Commit.

To attach it to an app, use the add-on's Connections list or the app's Add-ons tab. StackBlaze injects connection environment variables into the app. There is no Environment tab → Attach database flow. To inspect or add your own variables, use the app's Variables tab.

Injected environment variables

Every attached app receives host, port, and user variables. ClickHouse exposes a native TCP protocol on port 9000 and HTTP on port 8123.

VariableRole
CLICKHOUSE_HOSTInstance hostname
CLICKHOUSE_PORT9000 (native TCP)
CLICKHOUSE_HTTP_PORT8123 (HTTP)
CLICKHOUSE_USERDatabase user

When a password is set on the instance, StackBlaze also injects CLICKHOUSE_PASSWORD, plus CLICKHOUSE_URL and DATABASE_URL. Both URLs are the native protocol:

CLICKHOUSE_URL / DATABASE_URL (native)
clickhouse://user:password@host:9000

Use HTTP port 8123 for curl and HTTP clients. The injected CLICKHOUSE_URL is the native URL, not an HTTP URL.

Query over HTTP
curl "http://$CLICKHOUSE_HOST:$CLICKHOUSE_HTTP_PORT" \
  --user "$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD" \
  --data-binary "SELECT version()"

Browse and query with CloudBeaver

Every database add-on ships with CloudBeaver. Open with DB Beaver on the add-on's Overview starts a scoped session where you can browse tables, run SQL, and edit data in the browser.

Open with DB Beaver launches a scoped CloudBeaver session where the users table is browsed, a query runs, and the results appear.

Standard vs high availability

A Standard instance is a single ClickHouse server. It is a good fit for development and for analytics that fit comfortably on one node.

A High availability deployment uses sharding and replication. Replicated tables (using the ReplicatedMergeTree family of engines) are coordinated by ClickHouse Keeper, so each write is copied across replicas. Data survives the loss of a node, and shards spread data across servers so the cluster can scale beyond a single machine. You choose the deployment type when creating the instance.

StandardHigh availability
TopologySingle serverSharded and replicated
ReplicationNoneReplicatedMergeTree via ClickHouse Keeper
Survives node lossNoYes
Scales beyond one nodeNoYes (sharding)
Best forDev, single-node analyticsProduction, durability, scale

Querying

ClickHouse uses table engines to control how data is stored. The MergeTree engine is the standard choice for analytical tables.

Create, insert, select
CREATE TABLE events (
  id    UInt64,
  name  String,
  ts    DateTime
) ENGINE = MergeTree()
ORDER BY (ts, id);

INSERT INTO events VALUES (1, 'signup', now());

SELECT name, count() AS n
FROM events
GROUP BY name
ORDER BY n DESC;

Backups

Backups are not enabled automatically. Open the ClickHouse add-on, go to the Backups tab, and click Enable backups. From there you can use Backup now, Restore, and Schedule.

Restore always creates a new instance — there is no in-place restore. After the new instance is ready, switch the app connection to it from the add-on Connections list or the app Add-ons tab.

For the full backup workflow, see Backups & recovery.

Tip

Define an explicit ORDER BY key on your MergeTree tables. It determines how data is sorted on disk and has a large effect on query performance for analytical workloads.

Under the hood

ClickHouse is a columnar OLAP database built for fast analytical queries over large datasets. Native clients use port 9000; HTTP tools use port 8123. Attached apps receive those ports as CLICKHOUSE_PORT and CLICKHOUSE_HTTP_PORT.