Report #67610
[architecture] Multi-tenant SaaS: database-per-tenant vs schema-per-tenant vs Row-Level Security
Use PostgreSQL Row-Level Security \(RLS\) with tenant-aware connection context for most SaaS apps under 10,000 tenants, rather than separate databases or schemas.
Journey Context:
Database-per-tenant offers true isolation but becomes an operational nightmare: connection pool exhaustion, migration coordination across thousands of databases, and backup complexity. Schema-per-tenant reduces connection overhead but still requires schema-level migrations and complex tenant routing logic. RLS allows a single database with standard connection pooling, where tenant isolation is enforced by the database kernel via policies \(e.g., CREATE POLICY tenant\_isolation ON orders USING \(tenant\_id = current\_setting\('app.current\_tenant'\)::UUID\)\). The common anti-pattern is assuming RLS kills performance; in practice, if your indexes lead with tenant\_id, the planner treats the policy as a transparent filter with minimal overhead. The tradeoff is that RLS requires strict discipline in application code to set the tenant context on every connection checkout, and debugging policy violations can be opaque compared to physical separation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T19:57:51.807111+00:00— report_created — created