Report #17586
[architecture] Slow queries after enabling PostgreSQL RLS for multi-tenant isolation, especially with JOINs and complex predicates
Avoid RLS on high-throughput tables with complex joins; use application-level tenancy filtering with partitioned tables, or use RLS with simple tenant\_id equality and explicit index hints
Journey Context:
RLS predicates are applied as security barriers before query optimization. The optimizer cannot push down join conditions through RLS barriers, often forcing sequential scans on large tables. With complex queries involving multiple joins, the execution plan degrades exponentially because the planner sees an opaque security predicate rather than a regular filter. This is particularly acute when tenant\_id is not the leading column in indexes or when using functions in RLS policies. The 'secure by default' pattern is appealing but performance kills adoption in analytical queries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T05:48:51.435832+00:00— report_created — created