How to projection to different database? #2457
-
How to projection to different database? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
A strong -- an IMO very good -- concept of Marten is the use of transactional integrity. Thus an external / different database isn't possible by design. But you can make use of different ways to achieve this:
|
Beta Was this translation helpful? Give feedback.
-
But, CQRS said: |
Beta Was this translation helpful? Give feedback.
-
This is the type of thing you'd do at the Postgres level by running a replica (which is usually supported out of the box by most managed postgres hosts). You can then use Npgsql's load balancing support to split read/writes between primary and replica. |
Beta Was this translation helpful? Give feedback.
-
No, CQRS didn't say this. It's solely about separation of write (commands) and reads (queries). No word about the actual stores -- which BTW can be whatever fits best. Google / Bing for "cqrs myths" and you can read more about this. If you want to the CQRS-flavor with different write and read dbs, then you could use the outbox-pattern to update the read-db, which contains materialized views / projections for faster querying.
Maybe, it depends. But for sure it's way more work to develop, maintain, monitor, etc. For general one-write-db and multiple-read-dbs see @Hawxy's answer. |
Beta Was this translation helpful? Give feedback.
-
Hey folks, I'm moving this to a discussion just to get it out of my "OMG there's so many Marten issues that need fixing!" view:-) |
Beta Was this translation helpful? Give feedback.
No, CQRS didn't say this. It's solely about separation of write (commands) and reads (queries). No word about the actual stores -- which BTW can be whatever fits best. Google / Bing for "cqrs myths" and you can read more about this.
If you want to the CQRS-flavor with different write and read dbs, then you could use the outbox-pattern to update the read-db, which contains materialized views / projections for faster querying.
Maybe, it depends. But for sure it's way more work to develop, maintain, monitor, etc.
So go this route only if needed. To start I'd go with the same db for write and read side, so it's easy…