Designing multi-tenant Postgres for 10,000 organizations
Shared schema, schema-per-tenant, or database-per-tenant? A practical decision framework from ten enterprise builds, plus the row-level security patterns that hold up under load.

Three models, three cost curves
Every multi-tenant system lands on one of three isolation models. A shared schema keeps all tenants in the same tables with a tenant_id discriminator. Schema-per-tenant gives each customer its own set of tables inside one database. Database-per-tenant gives each customer their own database entirely.
The tradeoff is not technical purity, it is operating cost. Shared schema means one migration, one connection pool, and one backup policy. Database-per-tenant means those numbers multiply by your customer count. At 10,000 organizations, running 10,000 migrations on every release is not a deployment, it is a project.
- Shared schema: cheapest to run, hardest to isolate — the default for SaaS at scale.
- Schema-per-tenant: good for hundreds of tenants with custom fields, painful past a thousand.
- Database-per-tenant: reserve for regulated or enterprise customers who contractually require it.
Row-level security is the isolation boundary
If tenant filtering lives only in your ORM, one missing WHERE clause is a data breach. Push the boundary into Postgres. Enable row-level security on every tenant-scoped table and write a policy that compares tenant_id to a session variable set at connection checkout.
The application then sets the tenant context once per request. Queries that forget the filter return zero rows instead of somebody else's invoices. We treat any table without an RLS policy as a failing test in CI.
Indexing for tenant locality
The most common performance failure in shared-schema systems is an index that omits tenant_id. A query filtered by status and tenant will happily scan every tenant's rows to find the matching status values before filtering them away.
Make tenant_id the leading column of every composite index on a tenant-scoped table. Then partition your largest tables by tenant hash once single-table row counts pass a few hundred million — Postgres partition pruning keeps planning time flat.
Noisy neighbours and fair scheduling
One tenant running a 40-million-row export should not slow down the other 9,999. Put long-running work on a queue with per-tenant concurrency limits, apply statement timeouts on the interactive pool, and give reporting queries their own read replica with a separate connection pool.
The pattern that has survived every audit we have been through: interactive traffic on the primary with short timeouts, analytics on a replica, and background jobs metered per tenant.
When to break the model
Move a tenant to a dedicated database when one of three things is true: they contractually require physical isolation, they are more than roughly 20% of total load, or their compliance regime demands a separate backup and retention policy.
Design the escape hatch on day one — a tenant routing table that maps tenant_id to a connection string — even if every row points at the same cluster for the first three years.
Key takeaways
- Start with a shared schema and a tenant_id column on every table — it is the cheapest model to operate.
- Enforce isolation in the database with row-level security, never only in application code.
- Index on (tenant_id, <query column>) — a single-column index quietly scans other tenants' rows.
- Move only your largest tenants to dedicated databases, and only when metrics force it.
Working on something similar?
Talk it through with a senior engineer — no sales script, no obligation.
Request a free consultation