Remix.run Logo
kiwicopple 4 hours ago

clarifying a few misconceptions:

> RLS policies are executed per row

not necessarily. the planner integrates the policy expression into the query plan. stable/immutable expressions and indexable predicates aren't naively re-evaluated per row

> If SET LOCAL is omitted, current_setting() returns an empty string or throws an error depending on how your policy is written

if you're using tools like PostgREST, they set the GUC automatically per request

> RLS policies themselves are stored in pg_policies inside your database, not in your source code

Policies are plain DDL and are tracked by every serious migration tool. Off the top of my head, these tools track Policies: Sqitch, Flyway, Alembic, Atlas, Prisma migrate, dbmate

> Most migration tools do not include SQL functions

same as above