Report #10278
[architecture] Unexpected query performance degradation and plan regression with PostgreSQL Row-Level Security \(RLS\)
Avoid RLS for high-throughput OLTP queries; use explicit tenant\_id filters with composite indexes, or views with security barriers
Journey Context:
RLS appears ideal for multi-tenant isolation \(SET tenant\_id = current\_setting\('app.current\_tenant'\)\). However, the planner cannot optimize across RLS policy barriers, frequently forcing sequential scans. Leakproof functions restrict index usage. Security definer functions bypass RLS silently, creating security holes. Production pattern: explicit tenant\_id = ? in queries with \(tenant\_id, id\) composite indexes, or use schemas/views per tenant. Reserve RLS for low-volume administrative queries where performance is secondary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T10:15:22.356280+00:00— report_created — created