Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

Postgres Multi-Tenant Isolation: Schema-per-Tenant vs. Row-Level Security

Schema-per-tenant and row-level security isolate PostgreSQL data in different ways. Learn what each model depends on, where it can fail, and how to choose without assuming one is universally faster or safer.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

There is no universal winner. Schema-per-tenant separates tenant objects into namespaces and relies on PostgreSQL privileges; row-level security (RLS) keeps tenant rows in shared tables and uses policies to control ordinary access. Neither is a hard wall by label alone: schemas depend on safe privileges and name resolution, while RLS depends on complete policies, trustworthy tenant context, and roles that cannot bypass those policies.

How the two isolation models work

Schema-per-tenant

A PostgreSQL schema is a namespace for tables and other objects. Different schemas can contain objects with the same name, so an application can organize each tenant’s objects separately. But PostgreSQL explicitly says schemas in one database are not rigidly separated: a user who has the required privileges can access objects in another schema. A schema is therefore an organizational and privilege boundary, not an automatic security barrier. See PostgreSQL’s schema documentation.

As an Amazon Associate I earn from qualifying purchases.

Shared tables with RLS

In a pooled RLS design, tenants share tables, and rows are distinguished by a tenant key such as tenant_id. Once row security is enabled, normal access to rows must be allowed by an applicable policy. If no policy applies, PostgreSQL uses default deny. Policies can govern SELECT, INSERT, UPDATE, and DELETE. RLS adds a row-access layer alongside ordinary SQL privileges; it does not replace them. See PostgreSQL’s row security documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Compare the trade-offs that affect your design

Decision area Schema-per-tenant Shared tables with RLS
Data organization Tenant objects live in separate namespaces; object names can be reused across schemas. Tenant rows live in shared tables and are filtered through table policies.
What enforces access Schema and object privileges, ownership, and safe object-name resolution. RLS being enabled, applicable policies, reliable tenant context, and roles that do not bypass RLS.
Key security review Review schema USAGE and CREATE grants, ownership, search_path, and writable schemas. Review policy coverage and logic, application role behavior, tenant-context handling, and constraint-related information leakage.
Operational design Plan how tenant namespaces and grants are created, migrated, backed up, and audited. The cited PostgreSQL documentation does not quantify per-tenant migration costs. Ensure every tenant-data table is covered, context is set consistently, and application access uses intended roles.
Performance evidence The cited material provides no direct comparison or per-tenant-schema benchmark. PostgreSQL calls policies based only on the current row’s values the simplest and best-performing case when possible. That is not a claim that RLS is faster than separate schemas.

PostgreSQL’s documentation establishes these mechanics, but does not provide a head-to-head latency, throughput, storage, tenant-count, or migration-cost figure for the two designs. If performance is decisive, compare representative workloads in your own deployment rather than inferring a winner from the isolation model.

What to check before choosing

For schema-per-tenant: grants and name resolution

  • Grant only the schema and object privileges each role needs. Separate schema names do not prevent access when a role has privileges across schemas.
  • Review search_path wherever queries use unqualified object names. PostgreSQL warns that a schema on the search path is trusted: a user with CREATE privilege there can create objects that affect query behavior.
  • Check the deployed PostgreSQL version and configuration. PostgreSQL 15 and later support a private-schema secure usage pattern by default, while upgraded databases and older configurations may need public-schema CREATE privileges revoked. Confirm the actual grants and path settings rather than assuming the default applies.
  • Make tenant provisioning, grants, schema changes, backups, and audits repeatable. The mechanics are documented, but the workload-specific effort and migration cost must be established for your own system.

For RLS: role behavior and policy coverage

  • Run application queries under a role that is subject to RLS. Superusers and roles with BYPASSRLS always bypass policies. Table owners normally bypass them too, unless the table uses FORCE ROW LEVEL SECURITY.
  • Check every table that contains tenant data. AWS Prescriptive Guidance recommends enabling RLS on all such tables in its pooled PostgreSQL model; this is AWS’s guidance for that architecture, not a universal PostgreSQL mandate. See AWS Prescriptive Guidance on RLS for pooled PostgreSQL.
  • Define how each request establishes tenant context, and ensure the database comparison uses the intended tenant value. AWS’s example compares a tenant column with a runtime setting and favors runtime tenant context over creating a separate PostgreSQL user for every tenant.
  • Test normal reads and writes under the same roles the application will use, including paths where a tenant key is inserted or changed.

Review RLS policies by command and effect

USING and WITH CHECK do different jobs

A policy’s USING expression determines which existing rows are visible or available to a command. WITH CHECK determines whether a proposed new or changed row is allowed. Review both sides of inserts and updates: filtering which rows an application can target is not the same as validating the tenant identity of the row it writes.

Policy combinations can broaden or narrow access

Permissive policies are the default and combine with OR. Restrictive policies combine with AND. Review the complete set of applicable policies for each command and role; reading one policy in isolation may not reveal the effective access rule.

Constraints can reveal information outside RLS filtering

PostgreSQL’s referential-integrity checks bypass RLS so the database can preserve integrity. The documentation warns that constraint behavior can create covert information channels if policies and constraints are not designed carefully. Include constraint errors and cross-tenant references in security review and testing, especially where an error could reveal whether another tenant’s value exists. See PostgreSQL’s CREATE POLICY documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose based on your access model, not a tenant-count rule

Favor schema-per-tenant when separate namespaces fit the way you organize tenant objects and you can reliably manage schema privileges, ownership, and safe name resolution. Favor shared tables with RLS when pooled data and row-level access policies fit the application, and you can set tenant context consistently while ensuring application roles remain subject to RLS.

For either design, write down the intended boundary and test it using the actual application role. For RLS, test every tenant-data table and relevant command with tenant context set to different tenants and unset or invalid. For schema separation, test that roles cannot reach another tenant’s objects and that writable schemas cannot alter name resolution. PostgreSQL’s own guidance is: “As with any security settings, it’s important to test and ensure that the system is behaving as expected.”

The available official guidance does not establish a universal scale cutoff, security ranking, or performance winner. Compare migration and provisioning workflows, cross-tenant query needs, privilege design, and the threat model; use a representative workload benchmark if runtime performance determines the choice.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.