logoalt Hacker News

How we give every user SQL access to a shared ClickHouse cluster

48 pointsby eallamlast Tuesday at 3:50 PM58 commentsview on HN

Comments

zietoday at 11:43 AM

We do the same thing, every employee can access our main financial/back office SQL database, but we just use PostgreSQL with row level security[0]. We never bothered to complicate it like the post does.

0: https://www.postgresql.org/docs/18/ddl-rowsecurity.html

show 1 reply
cjonastoday at 1:09 PM

We just create mini data "ponds" on the fly by copying tenant isolated gold tier data to parquet in s3. The users/agent queries are executed with duckdb. We run this process when the user start a session and generate an STS token scoped to their tenant bucket path. Its extremely simple and works well (at least with our data volumes).

show 4 replies
senorribtoday at 11:42 AM

Reasons 1-3 could very well be done with ClickHouse policies (RLS) and good data warehouse design. In fact, that’s more secure than a compiler adding a where to a query ran by an all mighty user.

Reason 4 is probably an improvement, but could probably be done with CH functions.

The problem with custom DSLs like this is that tradeoff a massive ecosystem for very little benefit.

show 1 reply
jeldertoday at 12:42 PM

We did this with MotherDuck, and without introducing a new language. Every tenant has their own isolated storage and compute, so it’s trivial to grant internal users access to specific tenants as needed. DuckDB’s SQL dialect is mostly just Postgres’ with some nice ergonomic additions and a host of extra functionality.

show 1 reply
bob1029today at 2:25 PM

> How do you let users write arbitrary SQL against a shared multi-tenant analytical database without exposing other tenants' data or letting a rogue query take down the cluster?

For query operations I would try to find a way to solve this with tools like S3 and SQLite. There are a few VFS implementations for S3 and other CDNs.

show 1 reply
elnatrotoday at 1:01 PM

New to ClickHouse here. Would you thing this kind of database has a niche when compared to usual RDBMS like MySQL and PostgreSQL?

show 1 reply
devnotes77today at 2:04 PM

[dead]

xihe-forgetoday at 5:17 PM

[dead]

baalimagotoday at 1:09 PM

The evolution of this is to use agents, and have users "chat with the data"

show 1 reply