#Has anyone tried multi-tenancy in Payload CMS using a separate database per tenant?My idea is:

6 messages · Page 1 of 1 (latest)

plucky ember
#

Sounds like a migration nightmare.
I'm not sure how mongo handles joining queries across DB's, but Postgres was incredibly slow even with the DB's on the same server.

If separating the DB's is an absolute requirement, I'd set up separate environments.

hidden bridge
#

Nothing to migrate as I am not that far.
When using the multi tenancy plugin, lookup and searches filters out results from other tenants. I think it’s not ideal building indexes based on several tenants docs all mixed together.

plucky ember
#

True, ideally they would be composite indexes, with the field of interest and the tenant id

hidden bridge
#

That would for sure be an improvement yet eventually the option to go for separate database and separate cluster would be ideal. Can imagine shared collections is not ideal for very big collections.
Could go for separate deployments but if you want to keep things identical it sounds like something that can easily become a mess when you have to make sure all tenants are on the same pace.

plucky ember
#

I can't find it, but I remember a discussion where a Payload contributor said there is no direct support for dynamically switching DB's. You'd have to roll something custom.
Unless you're expecting to max out the resources of the DB servers, I don't see a benefit to this set-up. But that's an implementation detail for you.
Good luck 🙂