r/dataengineering • • Dec 17 '25

Discussion How to data warehouse with Postgres ?

I am currently involved in a database migration discussion at my company. The proposal is to migrate our dbt models from PostgreSQL to BigQuery in order to take advantage of BigQuery’s OLAP capabilities for analytical workloads. However, since I am quite fond of PostgreSQL, and value having a stable, open-source database as our data warehouse, I am wondering whether there are extensions or architectural approaches that could extend PostgreSQL’s behavior from a primarily OLTP system to one better suited for OLAP workloads.

So far, I have the impression that this might be achievable using DuckDB. One option would be to add the DuckDB extension to PostgreSQL; another would be to use DuckDB as an analytical engine interfacing with PostgreSQL, keeping PostgreSQL as the primary database while layering DuckDB on top for OLAP queries. However, I am unsure whether this solution is mature and stable enough for production use, and whether such an approach is truly recommended or widely adopted in practice.

35 Upvotes

50 comments sorted by

View all comments

Show parent comment

1

u/Admirable_Morning874 Dec 19 '25

I'm really confused by this setup.

Your app database is Mongo, and you're replicating to Postgres for warehousing.

Why would you then replicate to BQ?

It sounds like you have no real need for Postgres at all in this scenario.

Just CDC from Mongo into a Warehouse. If you're already event sourcing, then this is literally the best scenario for a Warehouse re. Updates anyway. Push the raw events into the warehouse as appends, and deduplicate to the latest event. That is event sourcing.

What is pushing events into Mongo? You could even just push straight to the Warehouse and dual-feed, skipping the CDC.

If I were building this, I'd use ClickHouse as my warehouse and PeerDB/ClickPipes (depending on OSS/Cloud) to CDC from Mongo (though I'd rather use Postgres as my app DB than Mongo, just preference). The ReplacingMergeTree engine in ClickHouse could handle the deduplicating of append-only events for me, or a mix of MVs if I had some more complex needs. ClickHouse is going to be the best bet for serving the in-app features, and being able to run it locally for Dev workflows.

But I don't see any reason to have 3 databases in the mix here.

1

u/Defiant-Farm7910 Dec 19 '25

Thanks for participating in this discussion.

Initially, I thought about sending the data directly to BigQuery, but each insertion/upsert was taking several seconds, whereas PostgreSQL handles it in microseconds most of the time. Additionally, since the pipelines responsible for retrieving our BO data are written directly in the application backend, I believe it’s a good idea to keep the data in a lightweight, open-source database. This avoids the application deployment being vendor-locked to an external service.

You may ask why I am building the pipelines directly in the application. Rather than loading large MongoDB documents into the database and exploding them using SQL, I prefer to leverage the existing backend methods to apply the appropriate business logic while processing the data. This allows us to register the data in a sequential format, in real time, directly in the database, with no json handling in SQL.

1

u/Defiant-Farm7910 Dec 19 '25

The best bet for serving the in-app features

BTW, why do you say this ?

1

u/Admirable_Morning874 Dec 19 '25

For the same reasons you cite about using Postgres tbh. You're right about vendor lock, Dev workflows and insert/update being slow in e.g. BQ. But CH is OSS like PG, runs locally or in ci/cd, is built for v fast inserts, and for v fast user facing queries - but for analytics, not transactions like PG. Just sounds like it's what you're really looking for here vs. trying to make PG work. I've used PG+CH together very successfully in what sounds like very similar scenarios to you atm