Report #53610
[architecture] How to architect database isolation for multi-tenant SaaS \(shared vs separate databases\)
Use schema-per-tenant \(PostgreSQL\) or database-per-tenant for strong isolation and compliance, but use row-level security \(RLS\) or tenant\_id column filtering for cost-efficient shared tables when strict isolation isn't required. Never rely solely on application-layer filtering.
Journey Context:
Three patterns exist: 1\) Shared database/shared schema \(cheapest, hardest to isolate\), 2\) Shared database/separate schemas \(PostgreSQL schemas\), 3\) Separate databases \(most expensive, best isolation\). The shared schema approach requires tenant\_id columns on every table and robust RLS policies \(PostgreSQL\) or rigorous query scoping. Schema-per-tenant allows backup/restore per tenant and easier migrations \(run same migration on each schema\), but connection pooling becomes complex \(search\_path or separate connections\). Database-per-tenant is overkill unless you have enterprise customers requiring physical separation. The common failure is 'tenant leakage' via missing WHERE clauses—use RLS or generated columns to make tenant scoping automatic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:28:49.901064+00:00— report_created — created