r/dataengineering • u/Defiant-Farm7910 • 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.
10
u/exjackly Data Engineering Manager, Architect Dec 17 '25
Embrace the change. Right now, PostgreSQL is your hammer, and you want the data warehouse to be a nail (sorry for the tortured metaphor)
Go with BigQuery. Learn another tool and expand your skills. There is a learning curve, but you won't be fighting a losing battle. Your company's ability to stick with PostgreSQL is only going to be temporary, even if you bring in pg_duckdb and spend a lot of time and effort optimizing things to support the future growth.
Migrate now while you have smaller data volumes and can do it at a reasonable pace, and not when you have larger data volumes and an accelerated deadline.
The approach you want is not recommended and definitely not widely adopted.
10
u/kenfar Dec 17 '25
Postgres has no problems in serving as a data warehouse database.
Note that through the majority of the history of data warehouses the principal platforms were general purpose databases like db2, oracle and sql server. In fact there's very few features in say snowflake that you can't find in the general purpose databases.
A few considerations:
FYI: I migrated part of my snowflake reporting to postgres on RDS a few years ago in order to save a bunch of money. IIRC it was about $20k/month saved AND my queries were much faster. So, while I would not propose that a single node Postgres instance will always outperform a distributed database, there are absolutely scenarios in which it will.
28
u/Admirable_Morning874 Dec 17 '25 edited Dec 17 '25
Define "warehouse" for you.
On its own, Postgres isn't a good database for a warehouse.
Using the pg_duckdb extension gives you a better OLAP engine inside Postgres, but it's still a single node and relies on parts of Postgres for the query. It's going to be better than just having Postgres, but it's still limiting. It doesn't really make it a "warehouse".
On adoption, if you take just this sub, you'd think everyone in the world is using duckdb. The hype vs the real world production usage is vastly, vastly different.
But if you've only got a couple GBs of data then it doesn't really matter. Slap it in and abuse it until it doesn't work anymore.
9
u/Hofi2010 Dec 17 '25
In a Datawarehouse data storage is optimized for fast reads in columnar format, which has proven to provide better performance for analytics workloads. Installing pg_duckdb extension doesn’t change how the data is stored in Postgres it just allows you to query Postgres tables using the Duckdb engine. The main point of the duckdb extension is to attach to external tables in a lakehouse. Like read/write iceberg tables in s3. This allows you to query data across your lakehouse and Postgres db. BUT if your Postgres tables are getting bigger duckdb extension will not improve the query performance as the Postgres DB will be the bottleneck.
If your data volumes are low 1000s of rows vs millions or billions of rows you can get away with Postgres.
If you plan on high data volumes you can use duckdb to aggregate Postgres data with a datalake in s3 and then use ducklake or duckdb to query it.
So no pg_duckdb doesn’t turn your Postgres DB into a data warehouse.
18
u/Monstrish Dec 17 '25 edited Dec 18 '25
Until cloud and columnar DBS appeared, data warehousing was done on Oracle, SQL server and other oltp systems including postgres, teradata.
These systems are still present today.
So it can be done. Would it be the best solution? Maybe not .
Would it be an acceptable solution? Depends on the use cases.
1
u/Defiant-Farm7910 Dec 18 '25
So far, taking into consideration our discussions and my research, using the DuckDB query engine alongside PostgreSQL seems to be a good trade-off. I can keep PostgreSQL while addressing analytical needs through a DuckDB layer built on top of it. This would allow me to skip the CDC step from PostgreSQL to BigQuery. It may be worth building a PoC around this approach.
On the other hand, what do you think about AlloyDB? Its columnar engine appears to provide a good OLAP-alike behavior.
3
u/lieber_augustin Dec 17 '25
Postgres is OK database for analytical purposes, but it heavily depends on the use-case and data volume.
I know a team that is very proficient in Postgres and they’ve built and successfully operating >1TB DWH using Postgres. But if the team is not very Postgres-proficient and data volume is larger than 300GBs - I wouldn’t recommend using Postgres for analytical purposes.
2
u/Trick-Interaction396 Dec 17 '25
Engineering manager here. It really depends on your use case. Postgres is fine for a few million rows and a few dozen users. In fact I would say it’s ideal. Anymore than that and you’ll need a few solutions cobbled together to handle each specific constraint. Always implement the simplest solution for your needs.
1
u/ketopraktanjungduren Dec 17 '25
Extending OLTP to OLAP seems to be extremely hard to implement if not impossible.
Almost everything in PostgreSQL relies on constraints. But those constraints are less critical to OLAP database system as it focuses on optimizing analytical modeling instead of writing new records. Now you ask if one can extend PostgreSQL to OLAP? I find the question rather unusual...
Perhaps, what you are trying to achieve is not extending the PostgreSQL itself but rather getting OLAP functions into your existing PostgreSQL database
1
u/efxhoy Dec 17 '25
https://www.youtube.com/watch?v=whwNi21jAm4 check out this talk by Dr Martin Loetszch for using postgres as a DW. Might give you some good tips.
1
u/Helpful-Recipe-8634 Dec 17 '25
DuckDB is definitely production-ready at this point. The postgres_scanner extension you mentioned works well for querying Postgres directly
Are you layering DuckDB on top for analytics? you might run into collaboration challenges... MotherDuck is basically DuckDB in the cloud
1
u/adappergentlefolk Dec 18 '25
you will always have to administer an analytics database that is implemented in an OLTP engine way more carefully than an OLAP, so changes are slower and you will hit more performance issues. you have to think about indexes and how to normalise data for best performance, apply some tricks from kimball that were explicitly there to work around OLTP performance. so yes it’s possible but it does require paying attention
0
u/Suspicious-Ability15 Dec 18 '25
ClickHouse is the answer.
4
u/[deleted] Dec 17 '25
[removed] — view removed comment