Report #69271
[architecture] Multi-tenant data isolation strategy for SaaS \(shared vs separate schemas\)
Use PostgreSQL Row-Level Security \(RLS\) with shared tables for <10k tenants requiring strict isolation but standard schemas; use schema-per-tenant only if tenants require heavy DB-level customization \(custom indexes, extensions\) or regulatory hard separation, but implement connection pooling carefully \(PgBouncer with pool\_mode=statement, not session\). Never use database-per-tenant for >100 tenants due to connection limits.
Journey Context:
Schema-per-tenant gives strong isolation \(SET search\_path\) but makes schema migrations painful \(running 1000 ALTER TABLEs\), breaks connection pooling \(each schema needs separate prepared statements\), and hits PostgreSQL catalog bloat. Shared table with tenant\_id column is flexible but risks cross-tenant data leakage via application bugs. RLS provides defense-in-depth: the database enforces tenant isolation regardless of application query construction. For MySQL, RLS doesn't exist \(until 8.0.1 with roles but not RLS policies\), so schema-per-tenant or application-level filtering is the only option. Connection limits \(PostgreSQL defaults to 100 max\_connections\) make database-per-tenant impossible for large scale.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:45:32.485629+00:00— report_created — created