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
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)
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.
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.
Have you considered other data sources? The idea is solid, I design Enterprise data warehouses for a living and with AI I have been wondering what's going to be next. Redshift/Snowflake, etc., have their pros but they don't come with predefined ingestion and access control.
Another question, how do you scale duckdb to multi user reads? I guess for you it's 1 file behind a node service? A typical data warehouse could have 1,000 concurrent users on a Monday morning.
hey kfk. Yeah, we've definitely been thinking about the potential for other datasources. E.g. we already have use-cases internally where being able to ingest from clickhouse, SQS and S3 would be big wins. Do you have particular sources in mind?
Great question about scalability. Mason right now has really been built for the BI use case, where you have lots of sporadic adhoc queries. It does this really well by dedicating every CPU to every query as it comes in, so it responds as quickly as possible. But, internally we also deal with lots of customer-facing analytics usecases, which is more like the case you describe: 1,000 concurrent users accessing a dashboard concurrently. For that case, the easiest thing to do is to simply give your machine more CPU and RAM (that will get to surprisingly far), but then beyond that we'd need to allow scaling the Mason readers horizontally. Definitely something we're going to look into.
ODBC is an interesting use-case. Not something we come across alot. Can i ask what your use-cases are there?
hum3hum3 | 19 hours ago
[OP] tagspace | 19 hours ago
ForHackernews | 17 hours ago
richardmeng | 19 hours ago
nylonstrung | 18 hours ago
Is pglite and the node stuff even necessary here?
[OP] tagspace | 18 hours ago
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?
aleda145 | 18 hours ago
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
NewJazz | 17 hours ago
[OP] tagspace | 17 hours ago
And yeah, it uses CDC via the WAL if you sync via logical replication.
aleda145 | 16 hours ago
alex_hirner | 16 hours ago
[OP] tagspace | 15 hours ago
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.
neilsimp1 | 16 hours ago
akshay180 | 15 hours ago
rightisleft | 12 hours ago
pratikgcet1985 | 15 hours ago
aiexplore369 | 7 hours ago
kfk | 6 hours ago
Another question, how do you scale duckdb to multi user reads? I guess for you it's 1 file behind a node service? A typical data warehouse could have 1,000 concurrent users on a Monday morning.
And any thoughts on temporary access tokens for odbc? A la https://medium.com/@shashwat_singh/hashicorp-vaults-dynamic-.... This is because I would rather not give any real password to AI agents.
[OP] tagspace | 4 hours ago
Great question about scalability. Mason right now has really been built for the BI use case, where you have lots of sporadic adhoc queries. It does this really well by dedicating every CPU to every query as it comes in, so it responds as quickly as possible. But, internally we also deal with lots of customer-facing analytics usecases, which is more like the case you describe: 1,000 concurrent users accessing a dashboard concurrently. For that case, the easiest thing to do is to simply give your machine more CPU and RAM (that will get to surprisingly far), but then beyond that we'd need to allow scaling the Mason readers horizontally. Definitely something we're going to look into.
ODBC is an interesting use-case. Not something we come across alot. Can i ask what your use-cases are there?
guy_louzon | an hour ago
[OP] tagspace | 48 minutes ago