SupabaseS
Supabase2mo ago
Thijs

Will this RLS policy be slow?

alter policy "Authenticated users can comment on followed/owned blogs"
on "public"."post_comments"
to authenticated
with check (
  (EXISTS ( SELECT 1
   FROM ((posts p
     JOIN blogs b ON ((b.id = p.blog_id)))
     LEFT JOIN blog_followers f ON (((f.blog_id = b.id) AND (f.user_id = ( SELECT auth.uid() AS uid)))))
  WHERE ((p.id = post_comments.post_id) AND ((f.user_id IS NOT NULL) OR (b.owner_id = ( SELECT auth.uid() AS uid))))))
);


I have this RLS policy, and a few more like this. Will this be slow in the long run? Should I change this, if so, how?
Was this page helpful?