ClickHouse
Managed ClickHouse on StackBlaze: a fast columnar OLAP database with single-node or replicated high-availability deployments.
Creating a ClickHouse instance
From the project canvas, click + Service → Databases → ClickHouse. 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.
| Variable | Role |
|---|---|
| CLICKHOUSE_HOST | Instance hostname |
| CLICKHOUSE_PORT | 9000 (native TCP) |
| CLICKHOUSE_HTTP_PORT | 8123 (HTTP) |
| CLICKHOUSE_USER | Database 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://user:password@host:9000Use HTTP port 8123 for curl and HTTP clients. The injected CLICKHOUSE_URL is the native URL, not an HTTP URL.
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.
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.
| Standard | High availability | |
|---|---|---|
| Topology | Single server | Sharded and replicated |
| Replication | None | ReplicatedMergeTree via ClickHouse Keeper |
| Survives node loss | No | Yes |
| Scales beyond one node | No | Yes (sharding) |
| Best for | Dev, single-node analytics | Production, durability, scale |
Querying
ClickHouse uses table engines to control how data is stored. The MergeTree engine is the standard choice for analytical tables.
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
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
9000; HTTP tools use port 8123. Attached apps receive those ports as CLICKHOUSE_PORT and CLICKHOUSE_HTTP_PORT.