Report #6853
[architecture] Multi-tenant data isolation strategy: Row-Level Security vs Schema-per-tenant
Use PostgreSQL Row-Level Security \(RLS\) with a \`tenant\_id\` column for SaaS applications under 10,000 tenants; reserve schema-per-tenant only for strict regulatory isolation or when tenants require divergent database schemas
Journey Context:
Schema-per-tenant provides perfect isolation and allows tenant-specific migrations, but causes connection pool exhaustion \(each connection requires \`search\_path\` changes\) and makes migrations O\(n\) with tenant count. RLS simplifies operations but requires \`tenant\_id\` as the leading column in all indexes to avoid sequential scans. A critical trap: superusers and table owners bypass RLS by default, requiring explicit \`FORCE ROW LEVEL SECURITY\` or using non-superuser roles for application connections. Alternative 'tenant view' patterns using SECURITY BARRIER views have performance overhead.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:13:04.836675+00:00— report_created — created