Skip to content

row_security

row_security is the PostgreSQL setting that controls whether PostgreSQL enables row security.
Note

Fact — official short description: “Enables row security.”

Identity

Type , Valuebool
Upstream pg_settings type
Context , Valueuser
Settable by an ordinary user
Unit , Value
Raw unit
Range , Value
Raw limits in the last observed version
Enum values , Value
— for non-enum types
Category , ValueClient Connection Defaults / Statement Behavior
Upstream classification
Latest boot value , Valueon
on

Lifecycle

Fact Value
First observed PG9.5
Present in PG9.5–19 Beta 3
Removed in No
Introduction commit 491c029dbc42 — Row-Level Security Policies (RLS)
Commit date 2014-09-19
Discussion

Default history

Measured PG9.0–19 Beta 3 boot defaults
Versions Raw boot_val Unit Human value
PG9.5–19 Beta 3 on on

How it works

row_security enables row security. When enabled, row security will be applied to all users. Off does not bypass policies for ordinary roles: it raises an error where a policy would apply, which lets tools such as pg_dump avoid silently incomplete results.

row_security is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.

Because session state can survive in pooled connections, role defaults, SET privilege, RESET behavior, and application checkout hooks are part of the control’s effective boundary.

Tuning advice

Tip

Advice. These are workload-specific starting points and must be validated with measurements.

Workload Guidance
OLTP Treat row_security as a correctness or security control, not a throughput knob. Grant SET authority narrowly and establish it from trusted role or application policy.
OLAP Use a dedicated analytical role if row_security must differ, and verify that exports, triggers, policies, and name resolution still preserve data correctness.
Small nodes Keep row_security at its safe default unless a documented repair or compatibility workflow requires otherwise; record and automatically restore temporary changes.

Pigsty

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

Template Effective value Versus upstream boot Source expression
OLTP Unmodified
OLAP Unmodified
CRIT Unmodified
TINY Unmodified
Caution

Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG9.5–19 Beta 3 unmodified; OLAP: PG9.5–19 Beta 3 unmodified; CRIT: PG9.5–19 Beta 3 unmodified; TINY: PG9.5–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

Common pitfalls

  • Changing row_security in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.
  • Granting broad SET rights to a control that can change correctness, policy enforcement, or name resolution.
  • Failing to reset a security-sensitive session value before a pooled connection is reused by another request.
  • Setting off expecting a bypass, although ordinary roles receive an error when a policy would apply.

search_path · session_replication_role · event_triggers · restrict_nonsystem_relation_kind · createrole_self_grant

References