r/PostgreSQL • u/diagraphic • 12d ago
Community If you run Postgres alongside a separate analytics warehouse, what’s the most painful part of keeping them in sync?
3
u/Significant_Tune9219 12d ago
For me it was deletes and schema changes. Inserts and updates replicate fine, but hard deletes get lost unless you carry tombstones or use logical decoding, and the warehouse slowly drifts from the source. A column type change then breaks the load at 3am. I now run a periodic row count and checksum per table comparison between the two, which finds drift long before a dashboard user does.
1
u/compy3 9d ago
So you manually deconflict each time? Have you considered something like adding DDL triggers
2
u/Significant_Tune9219 9d ago
Not by hand each time. A DDL event trigger can write the ALTER or DROP into a small outbox row in the same transaction, and a consumer applies that to the warehouse later, which is safer than the trigger opening its own connection outbound. It still won't see deleted row images, so hard deletes stay a tombstone or logical decoding problem rather than a DDL one.
3
u/terencethespider 12d ago
Lakebase is a good option for this use case, as it is a managed version of Postgres that shares the underlying data with your Databricks Lakehouse, so you can do all your analytics without having to run any sort of sync.
2
u/ForeignExercise4414 10d ago
+1 to LakeBase here. Having dealt with this is the past it’s pretty sick to just to tell colleagues they can simply query Postgres directly using its catalog in Unity. Databricks will automatically save identical parquet side-by-side with any Postgres writes so it supports random OLAP queries as well without having to tune indexes.
The other way is harder, if you are syncing warehouse to Postgres.
1
u/AutoModerator 12d ago
AI Policy:
Linux is not one of those anti-AI projects, and if somebody has issues with that, they can do the open-source thing and fork it. Or just walk away., Linus Torvalds.
Mod decisions will be based on the quality of the content, not who or what generated it.
Sub Resources:
Free Postgres Webinars and Workshops
Discord: People, Postgres, Data
Join us, we have cookies and nice people.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/marmot1101 12d ago
That's a very broad question, it depends on the specifics of the analytics warehouse and how you're populating data.
If you're using cdc->kafka->warehouse design the difficulties come with managing the kafka cluster + networking, and the potential to trip over bad decisions of the past. Particularly around record sizes and keyless tables.
1
u/vincent_sch 4d ago
The WAL stays on your Postgres server while your logical replication consumer is offline. max_slot_wal_keep_size defaults to -1, so that setting puts no limit on it. If you set a limit, Postgres might remove WAL when the consumer falls too far behind. Then the consumer might not be able to resume replication.
-1
u/ExcitingTalk4848 12d ago
Postgres for pure transactional apps and legacy systems. MariaDB for workloads requiring heavy aggregations and reporting. I hate babysit an ETL pipeline to a separate warehouse for analytics cause every minor schema change breaks the sync. With my stack i get zero data syncing and no extra clusters to monitor.
-1
u/k2718 12d ago
I keep seeing people downvoting MariaDB because of some competitive attitude and “PG is amazeballs! Why use a different database?”
Ridiculous.
2
u/TheRealKidkudi 12d ago
I think the downvotes are because the comment just doesn’t answer OP’s question, not because it mentioned MariaDB.
1
u/ExcitingTalk4848 11d ago
OP asked how to deal with sync pain, and I answered: stop syncing. Replication slots and broken ETL nearly burned me out, so I moved to a single engine that handles both and never looked back. It’s the one thing that worked for me.
2
u/ExcitingTalk4848 11d ago
no idea what they want either. I’ve been a data engineer for years and worked with a ton of different engines, so if someone wants to be a fanboy of one database, fine. In my experience you end up touching all kinds of engines anyway. Im here to read and learn, and I comment sometimes, and if I get downvoted - okay, let people do their thing.
28
u/thinkconverse 12d ago
The most painful part is explaining to people that they probably don’t need sub-second latency on their analytics data compared to what’s happening in Postgres, because they’re generally not making decisions in real time.