Report #5369
[architecture] Choosing isolation strategy for multi-tenant SaaS data architecture
Use PostgreSQL Row Level Security \(RLS\) with tenant\_id column over schema-per-tenant or database-per-tenant for most B2B SaaS. Enable RLS and create policies using current\_setting\('app.current\_tenant'\)::int with SET LOCAL in transaction.
Journey Context:
Schema-per-tenant provides strong isolation but causes connection pool exhaustion \(each schema needs connections\), slow migrations across thousands of schemas \(O\(n\) schema changes\), and operational complexity. Shared table with discriminator column risks developer error exposing wrong tenant data \(defense in depth failure\). RLS provides database-enforced tenant isolation regardless of application bug. Use SET LOCAL app.current\_tenant = ? in transaction or connection startup. Tradeoff: Slight query planning overhead \(policies checked per row\), requires careful testing of policies with EXPLAIN, complex for cross-tenant analytics \(needs bypass privileges or separate read replica without RLS\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:09:58.011363+00:00— report_created — created