Permissions Best Practices
Least-privilege patterns for PostgreSQL roles, grants, and RLS in production applications.
Search across all documentation pages
Least-privilege patterns for PostgreSQL roles, grants, and RLS in production applications.
app_api never owns tables.app_migrator role. DDL rights do not live in runtime pool.app_readers, app_writers, avoid per-developer logins on prod.CREATE on public schema.USAGE, SELECT on sequences.SELECT.tenant_id leftmost in composites.app_ro.app, public not $user, public only.app_owner NOLOGIN; migrator SET ROLE app_owner or inherits it. Runtime never connects as owner.
Both needed - grants allow table access; RLS filters rows within that access.
Stack versions: This page was written for PostgreSQL 18.4 (stable 18, maintenance 17), pgvector 0.8+, PgBouncer 1.x, Patroni 3.x, and PostGIS 3.5+.
Reviewed by Chris St. John·Last updated Jul 18, 2026