Row level security (RLS)

A Postgres feature that filters which rows a role can see or change, enforced by the database rather than the application.

With RLS enabled on a table, every query is silently constrained by a policy expression. A row that fails the policy is not returned, and a write that fails it is rejected — regardless of what the application asked for.

The value is that tenancy stops being a property of your code. A missing WHERE clause in one query cannot leak another customer's data, because the database will not produce those rows in the first place.

The usual mistake is enabling RLS and then routing everything through a service-role key that bypasses it. A service role is appropriate for a narrow, already-authorized server path — never as a general-purpose client.

Why it matters

It converts multi-tenant isolation from something you have to get right in every query into something the database guarantees once.