Comprehensive PostgreSQL reference for developers and DBAs covering versions 14–18. Use whenever the user asks about PostgreSQL syntax, DDL/DML/DQL, joins, LATERAL, CTEs, window functions, GROUPING SETS, DISTINCT ON, RETURNING, ON CONFLICT, PL/pgSQL, functions, procedures, triggers, views, materialized views, indexes (B-tree/GIN/GiST/BRIN/Hash/Bloom), MVCC, VACUUM, autovacuum, WAL, TOAST, partitioning, replication (streaming/logical), backup, PITR, HA (Patroni/repmgr), pgBouncer, EXPLAIN ANALYZE, RLS, roles, extensions (pgvector, PostGIS, TimescaleDB, Citus, pg_trgm, pg_cron), JSON/JSONB, full-text search, UUID, timestamptz, COPY, system catalogs, collations, large objects, cursors, GUC, or any Postgres administration, performance, security, replication, backup, or recovery topic.
94
94%
Does it follow best practices?
Impact
94%
1.36xAverage score across 3 eval scenarios
Passed
No known issues
An engineering team is building a multi-tenant SaaS application on PostgreSQL 16. Each tenant's data must be isolated so that users from one tenant can never read or modify another tenant's rows — even if they share the same database. The team has heard that PostgreSQL has a native mechanism to enforce this at the database layer rather than in application code, but is unsure how to set it up correctly or what pitfalls to watch out for.
The team includes both developers who are new to PostgreSQL security features and experienced DBAs who will maintain the system. They need a thorough technical guide they can embed in the team wiki. The guide should explain the core mechanism, show complete working examples, and cover operational gotchas — including what to expect from different deployment environments (self-hosted vs. managed cloud).
Write a single markdown file named rls_guide.md that serves as a self-contained reference guide.
The guide should include:
The SQL examples must be complete and runnable.
evals
references