3 ms·
Do you have much experience with it? Can you comment on the performance hit?
by catmanjan 5y ago
Do you have much experience with it? Can you comment on the performance hit?
- SahAssar 5y agoIn my experience the performance hit is not much larger than having the permission check part of your SELECT/UPDATE/DELETE query, but I don't have hard numbers.
- jansommer 5y agoThe performance hit can be quite big. I had a query that went from 1s to 400ms by disabling RLS. The security policy was a simple where org = abc. When I encounter performance hits like these, I refactor the slow query into a function with SECURITY DEFINER and a huge warning that you're on your own regarding security. Besides that, it's nice not having to worry if your SQL is accessing stuff the current role isn't allowed to see.
- agentultra 5y agoI do and the answer is always it depends. I'm not being glib! There are a lot of variables at play that will affect performances. In general it moves computation closer to the data and in aggregate that generally offsets most increases in query times. If you design your schemas carefully the performance cost is easy to swallow. As always analyze your queries under different table sizes and see what works for you. The benefit is that your application code doesn't have to use any complex RBAC->SQL compilation. You can just 'select foo, bar, baz from mytable;` and RLS will take care of making sure your application servers never see the data that the user doesn't have access to.