I'm very curious with the use case, why do you need to run analytical queries against the postgres read replica? Why not read the WAL and CDC them elsewhere? Especially if it's adhoc then the (short) delay wouldn't be noticeable.
Also did you tried transpiling SQL if you wanted to match the postgres dialect? I've had great success with duckdb <=> postgres using https://github.com/tobilg/polyglot
Sounds like they saw clickhouse as too operationally cumbersome and too much of a shift for their use cases. They seemed to want to reuse existing sql queries or fragments and just get a performance boost, and then also easy spin up these analytical DBs in customer environments on an ad-hoc basis.
Yeah, exactly. Our customers have lots of postgres dbs, and we needed something plug and play that we can throw the existing (postgres) queries at, without having to rewrite them. Also saves setting up a warehouse each time.
And yeah, it uses CDC via the WAL if you sync via logical replication.
I did something sort of similar which is to rewrite postgres so that I could use it against a single file sqlite DB and run in a browser with WASM. https://github.com/drummonds/go-postgres
Haven't tried it to be honest. Currently very lightweight and just syncs directly to the disk where you run it.
But duckdb supports both S3 and parquet so would likely be easy to support.
What's the usecase, if you don't mind me asking?
I guess the advantage is lower storage costs, but the read latency would take a hit (which would definitely affect query speeds). Would be interesting to try.
Good question. The majority of the work was two things:
1. the replication logic that keeps duckdb in sync with your postgres (like you'd expect from a read replica)
2. the query rewriter that takes incoming postgres queries and turns them into queries that run fast on duckdb (we've spent a lot of time making sure that most queries are answered in a few 100 milliseconds, even on 10+M rows).
So, I guess the main differences are:
- with ADBC the load still hits your postgres (which is what we wanted to avoid)
- with ADBC you're not guaranteed to get the same answer as postgres (we want confidence that our queries will answer the same, not faster but different)
- you'd have to build your own ETL (if you want to avoid the load on your postgres)
Cool! DuckDB is awesome
I'm very curious with the use case, why do you need to run analytical queries against the postgres read replica? Why not read the WAL and CDC them elsewhere? Especially if it's adhoc then the (short) delay wouldn't be noticeable.
Also did you tried transpiling SQL if you wanted to match the postgres dialect? I've had great success with duckdb <=> postgres using https://github.com/tobilg/polyglot
Sounds like they saw clickhouse as too operationally cumbersome and too much of a shift for their use cases. They seemed to want to reuse existing sql queries or fragments and just get a performance boost, and then also easy spin up these analytical DBs in customer environments on an ad-hoc basis.
Yeah, exactly. Our customers have lots of postgres dbs, and we needed something plug and play that we can throw the existing (postgres) queries at, without having to rewrite them. Also saves setting up a warehouse each time.
And yeah, it uses CDC via the WAL if you sync via logical replication.
Ah a fleet of customer postgres dbs! Makes sense, thanks for taking the time to explain
I did something sort of similar which is to rewrite postgres so that I could use it against a single file sqlite DB and run in a browser with WASM. https://github.com/drummonds/go-postgres
Ah nice. What do you use it for?
Sounds like https://pglite.dev/
Can replicated tables live on s3/parquet only, as in did you try so?
Haven't tried it to be honest. Currently very lightweight and just syncs directly to the disk where you run it.
But duckdb supports both S3 and parquet so would likely be easy to support.
What's the usecase, if you don't mind me asking?
I guess the advantage is lower storage costs, but the read latency would take a hit (which would definitely affect query speeds). Would be interesting to try.
Outside of the dashboard and team features stuff what does this add over just DuckDB + ADBC connected to postgres?
Is pglite and the node stuff even necessary here?
Good question. The majority of the work was two things:
1. the replication logic that keeps duckdb in sync with your postgres (like you'd expect from a read replica)
2. the query rewriter that takes incoming postgres queries and turns them into queries that run fast on duckdb (we've spent a lot of time making sure that most queries are answered in a few 100 milliseconds, even on 10+M rows).
So, I guess the main differences are:
- with ADBC the load still hits your postgres (which is what we wanted to avoid)
- with ADBC you're not guaranteed to get the same answer as postgres (we want confidence that our queries will answer the same, not faster but different)
- you'd have to build your own ETL (if you want to avoid the load on your postgres)
Does that make sense?
There are too many software projects with this name.
I have too many friends with this name
Very cool.