Report #12929
[architecture] Multi-tenant SaaS: choosing between schema-per-tenant vs row-level security
Use shared tables with Row Level Security \(RLS\) policies for most SaaS to avoid migration hell; reserve schema-per-tenant only when strict physical isolation is required for compliance \(e.g., HIPAA\), and use connection pooling middleware to handle thousands of schemas.
Journey Context:
Schema-per-tenant feels 'clean' \(true isolation, easy backup/restore per tenant\) but scales poorly: schema migrations require ALTER TABLE across thousands of schemas \(slow, error-prone\), connection pools break \(each schema may need separate search\_path or connections\), and operational visibility is fragmented. Row Level Security \(PostgreSQL\) or equivalent allows true data isolation in shared tables with policies like 'CREATE POLICY tenant\_isolation ON users FOR ALL TO app\_user USING \(tenant\_id = current\_setting\('app.current\_tenant'\)::int\);'. Tradeoffs: RLS adds slight query overhead \(check per row\), complex to implement correctly \(must set tenant context on every connection\), and bugs can expose data across tenants. Shared schema is operationally simpler for migrations and monitoring.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:19:05.579106+00:00— report_created — created