Hacker News new | past | comments | ask | show | jobs | submit login

Schemas[0] are the scalable way to do this, not databases, at least in Postgres.

If you're going to go this route you might also want to consider creating a role-per-user and taking advantage of the role-based security features[1].

That said, this is not how people usually handle multi-tenancy, for good reason, the complexity often outweighs the security benefit, there are good articles on it, and here's one by CitusData[2] (pre-acquisition).

[0]: https://www.postgresql.org/docs/current/ddl-schemas.html

[1]: https://www.postgresql.org/docs/current/ddl-rowsecurity.html

[2]: https://www.citusdata.com/blog/2016/10/03/designing-your-saa...




Schemas should be approached with extreme caution. They still suffer from the same issues as multiple databases, but now also you have to juggle search path and when I used schemas our databases backups were insane. This is because two same name tables with same name indexes can't be compressed together, as I understand it.

I would also be very careful about using roles this way as it makes connection pool formulas a lot more magical and less deterministic.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: